Class AbstractWeakPackedMap<K,​V>

    • Constructor Detail

      • AbstractWeakPackedMap

        public AbstractWeakPackedMap()
        Constructs an empty map.
      • AbstractWeakPackedMap

        public AbstractWeakPackedMap​(AbstractWeakPackedMap<K,​V> map)
        Constructs a map with the same mappings as the specified map.
        Parameters:
        map - the map whose mappings are to be placed in this map.
        Throws:
        NullPointerException - if the specified map is null.
    • Method Detail

      • containsKey

        public boolean containsKey​(Object key)
        Description copied from class: AbstractPackedMap
        Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key same than the given key (see AbstractPackedMap.isSame(Object, Object)). (There can be at most one such mapping.)
        Overrides:
        containsKey in class AbstractPackedMap<K,​V>
        Parameters:
        key - key whose presence in this map is to be tested.
        Returns:
        true if this map contains a mapping for the specified key.
      • containsValue

        public boolean containsValue​(@Nullable
                                     Object value)
        Description copied from class: AbstractPackedMap
        Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)). This operation requires time linear in the map size.
        Overrides:
        containsValue in class AbstractPackedMap<K,​V>
        Parameters:
        value - value whose presence in this map is to be tested.
        Returns:
        true if this map maps one or more keys to the specified value.
      • get

        @Nullable
        public V get​(Object key)
        Description copied from class: AbstractPackedMap
        Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

        More formally, if this map contains a mapping from a key k to a value v such that key is the same as k (see AbstractPackedMap.isSame(Object, Object)), then this method returns v otherwise it returns null. (There can be at most one such mapping.)

        A return value of null does not necessarily indicate that the map contains no mapping for the key: it is also possible that the map explicitly maps the key to null. The containsKey(key) operation may be used to distinguish these two cases.

        Overrides:
        get in class AbstractPackedMap<K,​V>
        Parameters:
        key - the key whose associated value is to be returned.
        Returns:
        the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      • keySet

        public Set<K> keySet()
        Description copied from class: AbstractPackedMap
        Returns an unmodifiable Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set cannot be modified and attempts to modify the returned collection, whether direct or via its iterator, result in an UnsupportedOperationException.
        Overrides:
        keySet in class AbstractPackedMap<K,​V>
        Returns:
        a set view of the keys contained in this map.
      • put

        @Nullable
        public V put​(K key,
                     V value)
        Description copied from class: AbstractPackedMap
        Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)
        Overrides:
        put in class AbstractPackedMap<K,​V>
        Parameters:
        key - key with which the specified value is to be associated.
        value - value to be associated with the specified key.
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)
      • remove

        @Nullable
        public V remove​(Object key)
        Description copied from class: AbstractPackedMap
        Removes the mapping for a key from this map if it is present. More formally, if this map contains a mapping for a key that is the same as the given key (see AbstractPackedMap.isSame(Object, Object)), that mapping is removed. (The map can contain at most one such mapping.)

        Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

        A return value of null does not necessarily indicate that the map contained no mapping for the key it's also possible that the map explicitly mapped the key to null.

        The map will not contain a mapping for the specified key once the call returns.

        Overrides:
        remove in class AbstractPackedMap<K,​V>
        Parameters:
        key - key whose mapping is to be removed from the map.
        Returns:
        the previous value associated with key, or null if there was no mapping for key.
      • size

        public int size()
        Description copied from class: AbstractPackedMap
        Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Overrides:
        size in class AbstractPackedMap<K,​V>
        Returns:
        the number of key-value mappings in this map
      • wrapKey

        protected Object wrapKey​(K key)
        Description copied from class: AbstractPackedMap
        Wraps a key. The result of this method will be stored in the packed map.

        By default, the key is returned.

        Overrides:
        wrapKey in class AbstractPackedMap<K,​V>
        Parameters:
        key - the key to wrap.
        Returns:
        the wrapped key.