Package com.jogamp.common.util
Class ArrayHashMap<K,V>
- java.lang.Object
-
- com.jogamp.common.util.ArrayHashMap<K,V>
-
public class ArrayHashMap<K,V> extends Object implements Cloneable, Map<K,V>
HashMapimplementation backed by anArrayListto 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. - Unique elements utilizing
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_INITIAL_CAPACITYThe default initial capacity: 16static floatDEFAULT_LOAD_FACTORDefault load factor: 0.75f
-
Constructor Summary
Constructors Constructor Description ArrayHashMap(boolean supportNullValue, int initialCapacity, float loadFactor)ArrayHashMap(ArrayHashMap<K,V> o)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Objectclone()Implementation usesArrayHashMap(ArrayHashMap).booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()booleanequals(Object arrayHashMap)Vget(Object key)ArrayList<V>getData()Returns this object ordered ArrayList.HashMap<K,V>getMap()Returns this object hash map.inthashCode()booleanisEmpty()Set<K>keySet()Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)Vremove(Object key)intsize()booleansupportsNullValue()Returnstruefor default behavior, i.e.ArrayList<V>toArrayList()StringtoString()Collection<V>values()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
DEFAULT_LOAD_FACTOR
public static final float DEFAULT_LOAD_FACTOR
Default load factor: 0.75f- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_INITIAL_CAPACITY
The default initial capacity: 16- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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:
supportsNullValue()
-
ArrayHashMap
public ArrayHashMap(ArrayHashMap<K,V> o)
-
-
Method Detail
-
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:
ArrayHashMap(boolean, int, float)
-
clone
public final Object clone()
Implementation usesArrayHashMap(ArrayHashMap).
-
getData
public final ArrayList<V> getData()
Returns this object ordered ArrayList. Use w/ care, it's not a copy.- See Also:
toArrayList()
-
toArrayList
public final ArrayList<V> toArrayList()
- Returns:
- a shallow copy of this ArrayHashMap's ArrayList, elements are not copied.
- See Also:
getData()
-
getMap
public final HashMap<K,V> getMap()
Returns this object hash map. Use w/ care, it's not a copy.
-
values
public Collection<V> values()
See
getData()andtoArrayList().
-
put
public final V put(K key, V value) throws NullPointerException
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
-
remove
public final V remove(Object key)
This is an O(1) operation, in case the key does not exist, otherwise O(n).
-
containsKey
public final boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
equals
public final boolean equals(Object arrayHashMap)
-
hashCode
public final int hashCode()
-
-