Class OffHeapLongIntMapImpl
java.lang.Object
express.mvp.roray.utils.collections.OffHeapLongIntMapImpl
- All Implemented Interfaces:
OffHeapLongIntMap, AutoCloseable
A linear-probing, open-addressing hash map with off-heap keys and off-heap int values.
Not thread-safe. Designed for single-threaded hot paths.
-
Constructor Summary
ConstructorsConstructorDescriptionOffHeapLongIntMapImpl(int capacity) OffHeapLongIntMapImpl(int capacity, int missingValue) Creates a new off-heap long-to-int map with specified capacity and missing value. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclose()Releases the underlying off-heap memory.booleancontainsKey(long key) intget(long key) Gets the value for the given key.booleanisEmpty()voidput(long key, int value) intremove(long key) Removes the key and returns its value.intsize()
-
Constructor Details
-
OffHeapLongIntMapImpl
public OffHeapLongIntMapImpl(int capacity, int missingValue) Creates a new off-heap long-to-int map with specified capacity and missing value.- Parameters:
capacity- the capacity (must be a power of 2)missingValue- the value returned for missing keys
-
OffHeapLongIntMapImpl
public OffHeapLongIntMapImpl(int capacity)
-
-
Method Details
-
get
public int get(long key) Description copied from interface:OffHeapLongIntMapGets the value for the given key.- Specified by:
getin interfaceOffHeapLongIntMap- Parameters:
key- The key.- Returns:
- The value, or the configured "missing value" (default -1) if not found.
-
put
public void put(long key, int value) - Specified by:
putin interfaceOffHeapLongIntMap
-
remove
public int remove(long key) Description copied from interface:OffHeapLongIntMapRemoves the key and returns its value.- Specified by:
removein interfaceOffHeapLongIntMap- Parameters:
key- The key to remove.- Returns:
- The value, or the "missing value" if not found.
-
clear
public void clear()- Specified by:
clearin interfaceOffHeapLongIntMap
-
size
public int size()- Specified by:
sizein interfaceOffHeapLongIntMap
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceOffHeapLongIntMap
-
containsKey
public boolean containsKey(long key) - Specified by:
containsKeyin interfaceOffHeapLongIntMap
-
close
public void close()Description copied from interface:OffHeapLongIntMapReleases the underlying off-heap memory.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceOffHeapLongIntMap
-