com.jogamp.common.util
Class LongObjectHashMap

java.lang.Object
  extended by com.jogamp.common.util.LongObjectHashMap
All Implemented Interfaces:
Iterable

public class LongObjectHashMap
extends Object
implements Iterable

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
See Also:
IntObjectHashMap, IntLongHashMap, IntIntHashMap, LongLongHashMap, LongIntHashMap

Nested Class Summary
static class LongObjectHashMap.Entry
          An entry mapping a key to a value.
 
Constructor Summary
LongObjectHashMap()
           
LongObjectHashMap(int initialCapacity)
           
LongObjectHashMap(int initialCapacity, float loadFactor)
           
 
Method Summary
 void clear()
          Clears the entire map.
 boolean containsKey(long key)
           
 boolean containsValue(Object value)
           
 Object get(long key)
          Returns the value to which the specified key is mapped, or getKeyNotFoundValue() if this map contains no mapping for the key.
 Object getKeyNotFoundValue()
          Returns the value which is returned if no value has been found for the specified key.
 Iterator<LongObjectHashMap.Entry> iterator()
          Returns a new Iterator.
 Object put(long key, Object value)
          Maps the key to the specified value.
 void putAll(LongObjectHashMap source)
          Copies all of the mappings from the specified map to this map.
 Object remove(long key)
          Removes the key-value mapping from this map.
 Object setKeyNotFoundValue(Object newKeyNotFoundValue)
          Sets the new key not found value.
 int size()
          Returns the current number of key-value mappings in this map.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LongObjectHashMap

public LongObjectHashMap()

LongObjectHashMap

public LongObjectHashMap(int initialCapacity)

LongObjectHashMap

public LongObjectHashMap(int initialCapacity,
                         float loadFactor)
Method Detail

containsValue

public boolean containsValue(Object value)

containsKey

public boolean containsKey(long key)

get

public Object get(long key)
Returns the value to which the specified key is mapped, or getKeyNotFoundValue() if this map contains no mapping for the key.


put

public Object put(long key,
                  Object value)
Maps the key to the specified value. If a mapping to this key already exists, the previous value will be returned (otherwise getKeyNotFoundValue()).


putAll

public void putAll(LongObjectHashMap source)
Copies all of the mappings from the specified map to this map.


remove

public Object remove(long key)
Removes the key-value mapping from this map. Returns the previously mapped value or getKeyNotFoundValue() if no such mapping exists.


size

public int size()
Returns the current number of key-value mappings in this map.


clear

public void clear()
Clears the entire map. The size is 0 after this operation.


iterator

public Iterator<LongObjectHashMap.Entry> iterator()
Returns a new Iterator. Note: this Iterator does not yet support removal of elements.

Specified by:
iterator in interface Iterable

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(long), put(long, 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(long), put(long, java.lang.Object)

toString

public String toString()
Overrides:
toString in class Object