Package com.jogamp.common.util
Class ArrayHashMap<K,V>
java.lang.Object
com.jogamp.common.util.ArrayHashMap<K,V>
HashMap implementation backed by an ArrayList to preserve order of values.
Implementation properties are:
- Unique elements utilizing
Object.hashCode()for O(1) operations, see below. - Java 1.5 compatible
- put new key-value-pair(s)
- test for containment
- trying to remove non existent elements
- put existing key-value-pair(s)
- removing existing elements
RecursiveLock.-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default initial capacity: 16static final floatDefault load factor: 0.75f -
Constructor Summary
ConstructorsConstructorDescriptionArrayHashMap(boolean supportNullValue, int initialCapacity, float loadFactor) ArrayHashMap(ArrayHashMap<K, V> o) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()final Objectclone()Implementation usesArrayHashMap(ArrayHashMap).final booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()final booleanfinal VgetData()Returns this object ordered ArrayList.getMap()Returns this object hash map.final inthashCode()final booleanisEmpty()keySet()final Vvoidfinal Vfinal intsize()final booleanReturnstruefor default behavior, i.e.final StringtoString()values()Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
DEFAULT_LOAD_FACTOR
public static final float DEFAULT_LOAD_FACTORDefault load factor: 0.75f- See Also:
-
DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_INITIAL_CAPACITYThe default initial capacity: 16- See Also:
-
-
Constructor Details
-
ArrayHashMap
public ArrayHashMap(boolean supportNullValue, int initialCapacity, float loadFactor) - Parameters:
supportNullValue- Usetruefor default behavior, i.e.nullcan be a valid value. Usefalseifnullis not a valid value, hereput(Object, Object)andremove(Object)will be optimized.initialCapacity- useDEFAULT_INITIAL_CAPACITYfor defaultloadFactor- useDEFAULT_LOAD_FACTORfor default- See Also:
-
ArrayHashMap
-
-
Method Details
-
supportsNullValue
public final boolean supportsNullValue()Returnstruefor default behavior, i.e.nullcan be a valid value.Returns
falseifnullis not a valid value, hereput(Object, Object)andremove(Object)are optimized operations.- See Also:
-
clone
Implementation usesArrayHashMap(ArrayHashMap). -
getData
Returns this object ordered ArrayList. Use w/ care, it's not a copy.- See Also:
-
toArrayList
- Returns:
- a shallow copy of this ArrayHashMap's ArrayList, elements are not copied.
- See Also:
-
getMap
Returns this object hash map. Use w/ care, it's not a copy. -
toString
-
clear
public final void clear() -
keySet
-
values
See
getData()andtoArrayList(). -
entrySet
-
get
-
put
This is an O(1) operation, in case the key does not exist, otherwise O(n).
- Specified by:
putin interfaceMap<K,V> - Throws:
NullPointerException- ifvalueisnullbutsupportsNullValue()==false
-
putAll
-
remove
This is an O(1) operation, in case the key does not exist, otherwise O(n).
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
equals
-
hashCode
public final int hashCode() -
isEmpty
public final boolean isEmpty() -
size
public final int size()
-