Class IdentityWeakHashMap<K,​V>

    • Field Detail

      • entries

        protected transient org.eclipse.persistence.internal.helper.IdentityWeakHashMap.WeakEntry<K,​V>[] entries
      • count

        protected transient int count
      • threshold

        protected int threshold
      • loadFactor

        protected float loadFactor
      • referenceQueue

        protected ReferenceQueue referenceQueue
        This is used by the garbage collector. Every weak reference that is garbage collected will be enqueued on this. Then only this queue needs to be checked to remove empty references.
    • Constructor Detail

      • IdentityWeakHashMap

        public IdentityWeakHashMap​(int initialCapacity,
                                   float loadFactor)
        Constructs a new IdentityWeakHashMap with the given initial capacity and the given loadFactor.
        Parameters:
        initialCapacity - the initial capacity of this IdentityWeakHashMap.
        loadFactor - the loadFactor of the IdentityWeakHashMap.
        Throws:
        IllegalArgumentException - if the initial capacity is less than zero, or if the loadFactor is nonpositive.
      • IdentityWeakHashMap

        public IdentityWeakHashMap​(int initialCapacity)
        Constructs a new IdentityWeakHashMap with the given initial capacity and a default loadFactor of 0.75.
        Parameters:
        initialCapacity - the initial capacity of the IdentityWeakHashMap.
        Throws:
        IllegalArgumentException - if the initial capacity is less than zero.
      • IdentityWeakHashMap

        public IdentityWeakHashMap()
        Constructs a new IdentityWeakHashMap with a default initial capacity of 32 and a loadfactor of 0.75.
      • IdentityWeakHashMap

        public IdentityWeakHashMap​(Map m)
        Constructs a new IdentityWeakHashMap with the same mappings as the given map. The IdentityWeakHashMap is created with a capacity sufficient to hold the elements of the given map.
        Parameters:
        m - the map whose mappings are to be placed in the IdentityWeakHashMap.
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface Map<K,​V>
        Overrides:
        size in class AbstractMap<K,​V>
        Returns:
        the size of this IdentityWeakHashMap.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Map<K,​V>
        Overrides:
        isEmpty in class AbstractMap<K,​V>
        Returns:
        true if this IdentityWeakHashMap is empty.
      • containsValue

        public boolean containsValue​(Object obj)
        Returns true if this IdentityWeakHashMap contains the given object. Equality is tested by the equals() method.
        Specified by:
        containsValue in interface Map<K,​V>
        Overrides:
        containsValue in class AbstractMap<K,​V>
        Parameters:
        obj - the object to find.
        Returns:
        true if this IdentityWeakHashMap contains obj.
        Throws:
        NullPointerException - if obj is null.
      • containsKey

        public boolean containsKey​(Object key)
        Returns true if this IdentityWeakHashMap contains a mapping for the given key. Equality is tested by reference.
        Specified by:
        containsKey in interface Map<K,​V>
        Overrides:
        containsKey in class AbstractMap<K,​V>
        Parameters:
        key - object to be used as a key into this IdentityWeakHashMap.
        Returns:
        true if this IdentityWeakHashMap contains a mapping for key.
      • get

        public V get​(Object key)
        Returns the value to which the given key is mapped in this IdentityWeakHashMap. Returns null if this IdentityWeakHashMap contains no mapping for this key.
        Specified by:
        get in interface Map<K,​V>
        Overrides:
        get in class AbstractMap<K,​V>
        Parameters:
        key - key whose associated value is to be returned.
        Returns:
        the value to which this IdentityWeakHashMap maps the given key.
      • put

        public V put​(K key,
                     V obj)
        Associate the given object with the given key in this IdentityWeakHashMap, replacing any existing mapping.
        Specified by:
        put in interface Map<K,​V>
        Overrides:
        put in class AbstractMap<K,​V>
        Parameters:
        key - key to map to given object.
        obj - object to be associated with key.
        Returns:
        the previous object for key or null if this IdentityWeakHashMap did not have one.
        Throws:
        NullPointerException - if obj is null.
      • remove

        public V remove​(Object key)
        Removes the mapping (key and its corresponding value) from this IdentityWeakHashMap, if present.
        Specified by:
        remove in interface Map<K,​V>
        Overrides:
        remove in class AbstractMap<K,​V>
        Parameters:
        key - key whose mapping is to be removed from the map.
        Returns:
        the previous object for key or null if this IdentityWeakHashMap did not have one.
      • removeEntry

        protected boolean removeEntry​(org.eclipse.persistence.internal.helper.IdentityWeakHashMap.WeakEntry o,
                                      boolean userModification)
      • putAll

        public void putAll​(Map<? extends K,​? extends V> m)
        Copies all of the mappings from the given map to this IdentityWeakHashMap, replacing any existing mappings.
        Specified by:
        putAll in interface Map<K,​V>
        Overrides:
        putAll in class AbstractMap<K,​V>
        Parameters:
        m - mappings to be stored in this IdentityWeakHashMap.
        Throws:
        NullPointerException - if m is null.
      • clear

        public void clear()
        Removes all of the mappings from this IdentityWeakHashMap.
        Specified by:
        clear in interface Map<K,​V>
        Overrides:
        clear in class AbstractMap<K,​V>
      • cleanUp

        protected void cleanUp()
      • clone

        public Object clone()
        Returns a shallow copy of this IdentityWeakHashMap (the elements are not cloned).
        Overrides:
        clone in class AbstractMap<K,​V>
        Returns:
        a shallow copy of this IdentityWeakHashMap.
      • keySet

        public Set keySet()
        Returns a set view of the keys contained in this IdentityWeakHashMap. The set is backed by the map, so changes to the map are reflected in the set, and vice versa. The set supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
        Specified by:
        keySet in interface Map<K,​V>
        Overrides:
        keySet in class AbstractMap<K,​V>
        Returns:
        a set view of the keys contained in this IdentityWeakHashMap.
      • values

        public Collection values()
        Returns a collection view of the values contained in this IdentityWeakHashMap. The collection is backed by the map, so changes to the map are reflected in the collection, and vice versa. The collection supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
        Specified by:
        values in interface Map<K,​V>
        Overrides:
        values in class AbstractMap<K,​V>
        Returns:
        a collection view of the values contained in this IdentityWeakHashMap.
      • entrySet

        public Set entrySet()
        Returns a collection view of the mappings contained in this IdentityWeakHashMap. Each element in the returned collection is a Map.Entry. The collection is backed by the map, so changes to the map are reflected in the collection, and vice versa. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
        Specified by:
        entrySet in interface Map<K,​V>
        Specified by:
        entrySet in class AbstractMap<K,​V>
        Returns:
        a collection view of the mappings contained in this IdentityWeakHashMap.