Package org.elasticsearch.common.util
Class LongObjectPagedHashMap<T>
- java.lang.Object
-
- org.elasticsearch.common.util.LongObjectPagedHashMap<T>
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Iterable<LongObjectPagedHashMap.Cursor<T>>
,Releasable
public class LongObjectPagedHashMap<T> extends java.lang.Object implements java.lang.Iterable<LongObjectPagedHashMap.Cursor<T>>
A hash table from native longs to objects. This implementation resolves collisions using open-addressing and does not support null values. This class is not thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LongObjectPagedHashMap.Cursor<T>
-
Constructor Summary
Constructors Constructor Description LongObjectPagedHashMap(long capacity, float maxLoadFactor, BigArrays bigArrays)
LongObjectPagedHashMap(long capacity, BigArrays bigArrays)
LongObjectPagedHashMap(BigArrays bigArrays)
-
Method Summary
Modifier and Type Method Description long
capacity()
Return the number of allocated slots to store this hash table.void
close()
T
get(long key)
Get the value that is associated withkey
or null ifkey
was not present in the hash table.protected void
grow()
java.util.Iterator<LongObjectPagedHashMap.Cursor<T>>
iterator()
T
put(long key, T value)
Put this new (key, value) pair into this hash table and return the value that was previously associated withkey
or null in case of an insertion.T
remove(long key)
Remove the entry which has this key in the hash table and return the associated value or null if there was no entry associated with this key.protected void
removeAndAdd(long index)
Remove the entry at the given index and add it backprotected void
resize(long capacity)
Resize to the given capacity.long
size()
Return the number of longs in this hash table.protected boolean
used(long bucket)
-
-
-
Method Detail
-
get
public T get(long key)
Get the value that is associated withkey
or null ifkey
was not present in the hash table.
-
put
public T put(long key, T value)
Put this new (key, value) pair into this hash table and return the value that was previously associated withkey
or null in case of an insertion.
-
remove
public T remove(long key)
Remove the entry which has this key in the hash table and return the associated value or null if there was no entry associated with this key.
-
iterator
public java.util.Iterator<LongObjectPagedHashMap.Cursor<T>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceReleasable
-
resize
protected void resize(long capacity)
Resize to the given capacity.
-
used
protected boolean used(long bucket)
-
removeAndAdd
protected void removeAndAdd(long index)
Remove the entry at the given index and add it back
-
capacity
public long capacity()
Return the number of allocated slots to store this hash table.
-
size
public long size()
Return the number of longs in this hash table.
-
grow
protected final void grow()
-
-