Package com.jogamp.common.util
Class IntObjectHashMap
- java.lang.Object
-
- com.jogamp.common.util.IntObjectHashMap
-
- All Implemented Interfaces:
Cloneable,Iterable<IntObjectHashMap.Entry>
public class IntObjectHashMap extends Object implements Cloneable, Iterable<IntObjectHashMap.Entry>
Fast HashMap for primitive data. Optimized for being GC friendly. Original code is based on the skorpios project released under new BSD license.- Author:
- Michael Bien, Simon Goller, Sven Gothel
- See Also:
IntIntHashMap,IntLongHashMap,LongObjectHashMap,LongLongHashMap,LongIntHashMap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntObjectHashMap.EntryAn entry mapping a key to a value.
-
Constructor Summary
Constructors Constructor Description IntObjectHashMap()IntObjectHashMap(int initialCapacity)IntObjectHashMap(int initialCapacity, float loadFactor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()Returns the current capacity (buckets) in this map.voidclear()Clears the entire map.Objectclone()Disclaimer: If the value type doesn't implementclone(), only the reference is copied.booleancontainsKey(int key)booleancontainsValue(Object value)Objectget(int key)Returns the value to which the specified key is mapped, orgetKeyNotFoundValue()if this map contains no mapping for the key.ObjectgetKeyNotFoundValue()Returns the value which is returned if no value has been found for the specified key.Iterator<IntObjectHashMap.Entry>iterator()Returns a newIterator.Objectput(int key, Object value)Maps the key to the specified value.voidputAll(IntObjectHashMap source)Copies all of the mappings from the specified map to this map.Objectremove(int key)Removes the key-value mapping from this map.ObjectsetKeyNotFoundValue(Object newKeyNotFoundValue)Sets the new key not found value.intsize()Returns the current number of key-value mappings in this map.StringtoString()StringBuildertoString(StringBuilder sb)-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
clone
public Object clone()
Disclaimer: If the value type doesn't implementclone(), only the reference is copied. Note: Due to private fields we cannot implement a copy constructor, sorry.
-
containsValue
public boolean containsValue(Object value)
-
containsKey
public boolean containsKey(int key)
-
get
public Object get(int key)
Returns the value to which the specified key is mapped, orgetKeyNotFoundValue()if this map contains no mapping for the key.
-
put
public Object put(int key, Object value)
Maps the key to the specified value. If a mapping to this key already exists, the previous value will be returned (otherwisegetKeyNotFoundValue()).
-
putAll
public void putAll(IntObjectHashMap source)
Copies all of the mappings from the specified map to this map.
-
remove
public Object remove(int key)
Removes the key-value mapping from this map. Returns the previously mapped value orgetKeyNotFoundValue()if no such mapping exists.
-
size
public int size()
Returns the current number of key-value mappings in this map.
-
capacity
public int capacity()
Returns the current capacity (buckets) in this map.
-
clear
public void clear()
Clears the entire map. The size is 0 after this operation.
-
iterator
public Iterator<IntObjectHashMap.Entry> iterator()
Returns a newIterator. Note: this Iterator does not yet support removal of elements.- Specified by:
iteratorin interfaceIterable<IntObjectHashMap.Entry>
-
setKeyNotFoundValue
public Object setKeyNotFoundValue(Object newKeyNotFoundValue)
Sets the new key not found value. For primitive types (int, long) the default is -1, for Object types, the default is null.- Returns:
- the previous key not found value
- See Also:
get(int),put(int, java.lang.Object)
-
getKeyNotFoundValue
public Object getKeyNotFoundValue()
Returns the value which is returned if no value has been found for the specified key.- See Also:
get(int),put(int, java.lang.Object)
-
toString
public StringBuilder toString(StringBuilder sb)
- Parameters:
sb- if null, a new StringBuilder is created- Returns:
- StringBuilder instance with appended string information of this Entry
-
-