Package org.jruby.util
Class WeakIdentityHashMap
java.lang.Object
org.jruby.util.GenericMap
org.jruby.util.WeakIdentityHashMap
- All Implemented Interfaces:
Map
Class
WeakIdentityHashMap is a hash map that hashes
objects based on System.identityHashMap, and holds weakly onto the
key. This fails if values make reference to the keys!- Since:
- 1.0
- Version:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class(package private) final classNested classes/interfaces inherited from class org.jruby.util.GenericMap
GenericMap.KeyIterator, GenericMap.KeyOrValueIterator, GenericMap.ValueIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final floatprivate static final Objectprivate final ReferenceQueueprivate intthe current range for table.private floatprivate WeakIdentityHashMap.Entry[]the hash indexFields inherited from class org.jruby.util.GenericMap
size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()private voidclear(int size) private booleancontainsKey(int hash, Object masked_key) booleancontainsKey(Object key) return the element with the given keyprotected Iteratorprivate voidexpunge()private Objectreturn the element with the given keyprivate voidgrow()private intindex(int hash) translate hash code bucket to indexbooleanisEmpty()protected final booleanprotected final intprivate Objectprivate Objectprivate voidintsize()private static Objectprotected voidvalueRemoved(Object value) Methods inherited from class org.jruby.util.GenericMap
containsValue, entrySet, equals, hashCode, keyIterator, keySet, putAll, valueEquals, valueHash, valueIterator, valuesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, values
-
Field Details
-
DEFAULT_RATIO
private static final float DEFAULT_RATIO- See Also:
-
NULL_KEY
-
queue
-
table
the hash index -
range
private int rangethe current range for table. -
ratio
private float ratio
-
-
Constructor Details
-
WeakIdentityHashMap
public WeakIdentityHashMap()the default and only constructor -
WeakIdentityHashMap
public WeakIdentityHashMap(int size)
-
-
Method Details
-
unmaskKey
-
maskKey
-
index
private int index(int hash) translate hash code bucket to index -
clear
public void clear() -
clear
private void clear(int size) -
expunge
private void expunge() -
get
return the element with the given key -
get
-
containsKey
return the element with the given key- Specified by:
containsKeyin interfaceMap- Overrides:
containsKeyin classGenericMap
-
containsKey
-
put
-
put
-
remove
-
remove
-
removeEntry
-
valueRemoved
-
grow
private void grow() -
entryIterator
- Specified by:
entryIteratorin classGenericMap
-
keyHash
- Overrides:
keyHashin classGenericMap
-
keyEquals
- Overrides:
keyEqualsin classGenericMap
-
size
public int size()- Specified by:
sizein interfaceMap- Overrides:
sizein classGenericMap
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceMap- Overrides:
isEmptyin classGenericMap
-