Class FastObjectIntMap<K>
java.lang.Object
gaiasky.util.FastObjectIntMap<K>
- Type Parameters:
K- the type of keys maintained by this map
A high-performance map implementation that stores object keys and unboxed int values.
This implementation uses open addressing with linear probing to reduce memory overhead
and avoid boxing of integer values.
-
Constructor Summary
ConstructorsConstructorDescriptionFastObjectIntMap(int initialCapacity, Class<K> c) Constructs a new map with the specified initial capacity and key class. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(K key) Checks if the map contains the specified key.intReturns the value associated with the specified key, or 0 if not found.K[]keys()Returns an array of all keys in the map.voidAssociates the specified value with the specified key in the map.intsize()Returns the number of key-value mappings in the map.
-
Constructor Details
-
FastObjectIntMap
-
-
Method Details
-
get
Returns the value associated with the specified key, or 0 if not found.- Parameters:
key- the key- Returns:
- the associated value, or 0 if the key is not present
-
put
Associates the specified value with the specified key in the map. If the key already exists, its value will be overwritten.- Parameters:
key- the keyvalue- the value
-
containsKey
Checks if the map contains the specified key.- Parameters:
key- the key to check- Returns:
- true if the key is present, false otherwise
-
keys
Returns an array of all keys in the map. This is the internal array, so it is subject to change. Also, it may contain null values- Returns:
- an array containing all keys in the map
-
size
public int size()Returns the number of key-value mappings in the map.- Returns:
- the size of the map
-