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

public Class IntLongHashMap

extends Object
implements Cloneable, Iterable<IntLongHashMap.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, IntIntHashMap, LongObjectHashMap, LongLongHashMap, LongIntHashMap

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
IntLongHashMap.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<IntLongHashMap.Entry>
private static final Method
private static final boolean
private long
private final float
private int
private int
private IntLongHashMap.Entry[]
private int

Constructor Summary

AccessConstructor and Description
public
public
IntLongHashMap(final int initialCapacity)

public
IntLongHashMap(final int initialCapacity, final float loadFactor)

private
IntLongHashMap(final float loadFactor, final int table_size, final int size, final int mask, final int capacity, final int threshold, final long 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 int key)

public boolean
containsValue(final long value)

public long
get(final int 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 long
getKeyNotFoundValue()

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

public Iterator<IntLongHashMap.Entry>
iterator()

Implements java.lang.Iterable.iterator.

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

Maps the key to the specified value.

public void
putAll(final IntLongHashMap source)

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

public long
remove(final int key)

Removes the key-value mapping from this map.

public long

Returns:

the previous key not found value
setKeyNotFoundValue
(final long 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<IntLongHashMap.Entry> entryConstructor
equalsMethodback to summary
private static final Method equalsMethod
isPrimitiveback to summary
private static final boolean isPrimitive
keyNotFoundValueback to summary
private long keyNotFoundValue
loadFactorback to summary
private final float loadFactor
maskback to summary
private int mask
sizeback to summary
private int size
tableback to summary
private IntLongHashMap.Entry[] table
thresholdback to summary
private int threshold

Constructor Detail

IntLongHashMapback to summary
public IntLongHashMap()
IntLongHashMapback to summary
public IntLongHashMap(final int initialCapacity)
IntLongHashMapback to summary
public IntLongHashMap(final int initialCapacity, final float loadFactor)
IntLongHashMapback to summary
private IntLongHashMap(final float loadFactor, final int table_size, final int size, final int mask, final int capacity, final int threshold, final long 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 int key)
containsValueback to summary
public boolean containsValue(final long value)
getback to summary
public long get(final int 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 long 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<IntLongHashMap.Entry> iterator()

Implements java.lang.Iterable.iterator.

Returns a new Iterator.

Note

this Iterator does not yet support removal of elements.

Returns:Iterator<IntLongHashMap.Entry>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
putback to summary
public long put(final int key, final long 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 IntLongHashMap source)

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

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

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 IntLongHashMap.Entry

extends Object
Class Inheritance

An entry mapping a key to a value.

Field Summary

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

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public int
getKey()

Returns the key of this entry.

public long
getValue()

Returns the value of this entry.

public void
setValue(final long 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 int key
nextback to summary
pack-priv IntLongHashMap.Entry next
valueback to summary
public long value

Constructor Detail

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

Method Detail

getKeyback to summary
public int getKey()

Returns the key of this entry.

getValueback to summary
public long getValue()

Returns the value of this entry.

setValueback to summary
public void setValue(final long 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 IntLongHashMap.EntryCM

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Constructor<IntLongHashMap.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<IntLongHashMap.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 IntLongHashMap.EntryIterator

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

Field Summary

Modifier and TypeField and Description
private final IntLongHashMap.Entry[]
private int
private IntLongHashMap.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 IntLongHashMap.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 IntLongHashMap.Entry[] entries
indexback to summary
private int index
nextback to summary
private IntLongHashMap.Entry next

Constructor Detail

EntryIteratorback to summary
private EntryIterator(final IntLongHashMap.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 IntLongHashMap.Entry next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:IntLongHashMap.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