Class FastStringObjectMap<V>
java.lang.Object
gaiasky.util.FastStringObjectMap<V>
- Type Parameters:
V- the type of values maintained by this map
A high-performance map implementation that stores String keys and generic Object values.
This implementation uses open addressing with linear probing to reduce memory overhead
and avoid boxing of integer values.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new map with the default initial capacity.FastStringObjectMap(int initialCapacity) Constructs a new map with the specified initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the map, and re-initializes it with the original initial capacity.booleancontainsKey(String key) Checks if the map contains the specified key.Returns the value associated with the specified key, or null if not found.String[]keys()Returns an array of all keys in the map.voidAssociates the specified value with the specified key in the map.Removes the mapping for the specified key from this map if present.intsize()Returns the number of key-value mappings in the map.
-
Constructor Details
-
FastStringObjectMap
public FastStringObjectMap()Constructs a new map with the default initial capacity. -
FastStringObjectMap
public FastStringObjectMap(int initialCapacity) Constructs a new map with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity
-
-
Method Details
-
clear
public void clear()Clears the map, and re-initializes it with the original initial capacity. -
get
-
put
-
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
-
remove
-
size
public int size()Returns the number of key-value mappings in the map.- Returns:
- the size of the map
-