Top Description Inners Fields Constructors Methods
com.jogamp.common.util

public Class LongIntHashMap

extends Object
implements Cloneable, Iterable<LongIntHashMap.Entry>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, java.lang.Cloneable
Imports
com.jogamp.common.JogampRuntimeException, java.lang.reflect.Constructor, .Method, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .Arrays, .Iterator

Fast HashMap for primitive data. Optimized for being GC friendly. Original code is based on the skorpios project released under new BSD license.
Authors
Michael Bien, Simon Goller, Sven Gothel
See Also
IntObjectHashMap, IntLongHashMap, LongObjectHashMap, LongLongHashMap, IntIntHashMap

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LongIntHashMap.Entry

An entry mapping a key to a value.

pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private int
private static final Constructor<LongIntHashMap.Entry>
private static final Method
private static final boolean
private int
private final float
private int
private int
private LongIntHashMap.Entry[]
private int

Constructor Summary

AccessConstructor and Description
public
public
LongIntHashMap(final int initialCapacity)

public
LongIntHashMap(final int initialCapacity, final float loadFactor)

private
LongIntHashMap(final float loadFactor, final int table_size, final int size, final int mask, final int capacity, final int threshold, final int keyNotFoundValue)

Method Summary

Modifier and TypeMethod and Description
public int
capacity()

Returns the current capacity (buckets) in this map.

public void
clear()

Clears the entire map.

public Object
clone()

Overrides java.lang.Object.clone.

Disclaimer

If the value type doesn't implement clone(), only the reference is copied.

public boolean
containsKey(final long key)

public boolean
containsValue(final int value)

public int
get(final long key)

Returns the value to which the specified key is mapped, or getKeyNotFoundValue if this map contains no mapping for the key.

private static Method
public int
getKeyNotFoundValue()

Returns the value which is returned if no value has been found for the specified key.

public Iterator<LongIntHashMap.Entry>
iterator()

Implements java.lang.Iterable.iterator.

Returns a new Iterator.
public int
put(final long key, final int value)

Maps the key to the specified value.

public void
putAll(final LongIntHashMap source)

Copies all of the mappings from the specified map to this map.

public int
remove(final long key)

Removes the key-value mapping from this map.

public int

Returns:

the previous key not found value
setKeyNotFoundValue
(final int newKeyNotFoundValue)

Sets the new key not found value.

public int
size()

Returns the current number of key-value mappings in this map.

public StringBuilder

Returns:

StringBuilder instance with appended string information of this Entry
toString
(StringBuilder
if null, a new StringBuilder is created
sb
)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

capacityback to summary
private int capacity
entryConstructorback to summary
private static final Constructor<LongIntHashMap.Entry> entryConstructor
equalsMethodback to summary
private static final Method equalsMethod
isPrimitiveback to summary
private static final boolean isPrimitive
keyNotFoundValueback to summary
private int keyNotFoundValue
loadFactorback to summary
private final float loadFactor
maskback to summary
private int mask
sizeback to summary
private int size
tableback to summary
private LongIntHashMap.Entry[] table
thresholdback to summary
private int threshold

Constructor Detail

LongIntHashMapback to summary
public LongIntHashMap()
LongIntHashMapback to summary
public LongIntHashMap(final int initialCapacity)
LongIntHashMapback to summary
public LongIntHashMap(final int initialCapacity, final float loadFactor)
LongIntHashMapback to summary
private LongIntHashMap(final float loadFactor, final int table_size, final int size, final int mask, final int capacity, final int threshold, final int keyNotFoundValue)

Method Detail

capacityback to summary
public int capacity()

Returns the current capacity (buckets) in this map.

clearback to summary
public void clear()

Clears the entire map. The size is 0 after this operation.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Disclaimer

If the value type doesn't implement clone(), only the reference is copied.

Note

Due to private fields we cannot implement a copy constructor, sorry.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
containsKeyback to summary
public boolean containsKey(final long key)
containsValueback to summary
public boolean containsValue(final int value)
getback to summary
public int get(final long key)

Returns the value to which the specified key is mapped, or getKeyNotFoundValue if this map contains no mapping for the key.

getCloneMethodback to summary
private static Method getCloneMethod(final Object obj)
getKeyNotFoundValueback to summary
public int getKeyNotFoundValue()

Returns the value which is returned if no value has been found for the specified key.

See Also
get, put
iteratorback to summary
public Iterator<LongIntHashMap.Entry> iterator()

Implements java.lang.Iterable.iterator.

Returns a new Iterator.

Note

this Iterator does not yet support removal of elements.

Returns:Iterator<LongIntHashMap.Entry>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
putback to summary
public int put(final long key, final int value)

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

putAllback to summary
public void putAll(final LongIntHashMap source)

Copies all of the mappings from the specified map to this map.

removeback to summary
public int remove(final long key)

Removes the key-value mapping from this map. Returns the previously mapped value or getKeyNotFoundValue if no such mapping exists.

setKeyNotFoundValueback to summary
public int setKeyNotFoundValue(final int 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:int

the previous key not found value

See Also
get, put
sizeback to summary
public int size()

Returns the current number of key-value mappings in this map.

toStringback to summary
public StringBuilder toString(StringBuilder sb)
Parameters
sb:StringBuilder

if null, a new StringBuilder is created

Returns:StringBuilder

StringBuilder instance with appended string information of this Entry

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.common.util back to summary

public final Class LongIntHashMap.Entry

extends Object
Class Inheritance

An entry mapping a key to a value.

Field Summary

Modifier and TypeField and Description
public final long
pack-priv LongIntHashMap.Entry
public int

Constructor Summary

AccessConstructor and Description
pack-priv
Entry(final long k, final int v, final LongIntHashMap.Entry n)

Method Summary

Modifier and TypeMethod and Description
public long
getKey()

Returns the key of this entry.

public int
getValue()

Returns the value of this entry.

public void
setValue(final int value)

Sets the value for this entry.

public StringBuilder

Returns:

StringBuilder instance with appended string information of this Entry
toString
(StringBuilder
if null, a new StringBuilder is created
sb
)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

keyback to summary
public final long key
nextback to summary
pack-priv LongIntHashMap.Entry next
valueback to summary
public int value

Constructor Detail

Entryback to summary
pack-priv Entry(final long k, final int v, final LongIntHashMap.Entry n)

Method Detail

getKeyback to summary
public long getKey()

Returns the key of this entry.

getValueback to summary
public int getValue()

Returns the value of this entry.

setValueback to summary
public void setValue(final int value)

Sets the value for this entry.

toStringback to summary
public StringBuilder toString(StringBuilder sb)
Parameters
sb:StringBuilder

if null, a new StringBuilder is created

Returns:StringBuilder

StringBuilder instance with appended string information of this Entry

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.common.util back to summary

pack-priv Class LongIntHashMap.EntryCM

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Constructor<LongIntHashMap.Entry>
c

pack-priv Method

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cback to summary
pack-priv Constructor<LongIntHashMap.Entry> c
m1back to summary
pack-priv Method m1

Constructor Detail

EntryCMback to summary
pack-priv EntryCM()
com.jogamp.common.util back to summary

private final Class LongIntHashMap.EntryIterator

extends Object
implements Iterator<LongIntHashMap.Entry>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final LongIntHashMap.Entry[]
private int
private LongIntHashMap.Entry

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public LongIntHashMap.Entry
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final LongIntHashMap.Entry[] entries
indexback to summary
private int index
nextback to summary
private LongIntHashMap.Entry next

Constructor Detail

EntryIteratorback to summary
private EntryIterator(final LongIntHashMap.Entry[] entries)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public LongIntHashMap.Entry next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:LongIntHashMap.Entry

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override