Class IdentityWeakHashMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.eclipse.persistence.internal.helper.IdentityWeakHashMap<K,V>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<K,V>
public class IdentityWeakHashMap<K,V> extends java.util.AbstractMap<K,V> implements java.util.Map<K,V>, java.lang.Cloneable, java.io.Serializable- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcountprotected org.eclipse.persistence.internal.helper.IdentityWeakHashMap.WeakEntry<K,V>[]entriesprotected floatloadFactorprotected java.lang.ref.ReferenceQueuereferenceQueueThis is used by the garbage collector.protected intthreshold
-
Constructor Summary
Constructors Constructor Description IdentityWeakHashMap()Constructs a new IdentityWeakHashMap with a default initial capacity of 32 and a loadfactor of 0.75.IdentityWeakHashMap(int initialCapacity)Constructs a new IdentityWeakHashMap with the given initial capacity and a default loadFactor of 0.75.IdentityWeakHashMap(int initialCapacity, float loadFactor)Constructs a new IdentityWeakHashMap with the given initial capacity and the given loadFactor.IdentityWeakHashMap(java.util.Map m)Constructs a new IdentityWeakHashMap with the same mappings as the given map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanUp()voidclear()Removes all of the mappings from this IdentityWeakHashMap.java.lang.Objectclone()Returns a shallow copy of this IdentityWeakHashMap (the elements are not cloned).booleancontainsKey(java.lang.Object key)Returns true if this IdentityWeakHashMap contains a mapping for the given key.booleancontainsValue(java.lang.Object obj)Returns true if this IdentityWeakHashMap contains the given object.java.util.SetentrySet()Returns a collection view of the mappings contained in this IdentityWeakHashMap.Vget(java.lang.Object key)Returns the value to which the given key is mapped in this IdentityWeakHashMap.booleanisEmpty()java.util.SetkeySet()Returns a set view of the keys contained in this IdentityWeakHashMap.Vput(K key, V obj)Associate the given object with the given key in this IdentityWeakHashMap, replacing any existing mapping.voidputAll(java.util.Map<? extends K,? extends V> m)Copies all of the mappings from the given map to this IdentityWeakHashMap, replacing any existing mappings.Vremove(java.lang.Object key)Removes the mapping (key and its corresponding value) from this IdentityWeakHashMap, if present.protected booleanremoveEntry(org.eclipse.persistence.internal.helper.IdentityWeakHashMap.WeakEntry o, boolean userModification)intsize()java.util.Collectionvalues()Returns a collection view of the values contained in this IdentityWeakHashMap.
-
-
-
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 java.lang.ref.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:
java.lang.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.
-
IdentityWeakHashMap
public IdentityWeakHashMap()
Constructs a new IdentityWeakHashMap with a default initial capacity of 32 and a loadfactor of 0.75.
-
IdentityWeakHashMap
public IdentityWeakHashMap(java.util.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()
-
isEmpty
public boolean isEmpty()
-
containsValue
public boolean containsValue(java.lang.Object obj)
Returns true if this IdentityWeakHashMap contains the given object. Equality is tested by the equals() method.
-
containsKey
public boolean containsKey(java.lang.Object key)
Returns true if this IdentityWeakHashMap contains a mapping for the given key. Equality is tested by reference.
-
get
public V get(java.lang.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.
-
put
public V put(K key, V obj)
Associate the given object with the given key in this IdentityWeakHashMap, replacing any existing mapping.
-
remove
public V remove(java.lang.Object key)
Removes the mapping (key and its corresponding value) from this IdentityWeakHashMap, if present.
-
removeEntry
protected boolean removeEntry(org.eclipse.persistence.internal.helper.IdentityWeakHashMap.WeakEntry o, boolean userModification)
-
putAll
public void putAll(java.util.Map<? extends K,? extends V> m)
Copies all of the mappings from the given map to this IdentityWeakHashMap, replacing any existing mappings.
-
clear
public void clear()
Removes all of the mappings from this IdentityWeakHashMap.
-
cleanUp
protected void cleanUp()
-
clone
public java.lang.Object clone()
Returns a shallow copy of this IdentityWeakHashMap (the elements are not cloned).
-
keySet
public java.util.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.
-
values
public java.util.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.
-
entrySet
public java.util.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.
-
-