Class FastStringObjectMap<V>

java.lang.Object
gaiasky.util.FastStringObjectMap<V>
Type Parameters:
V - the type of values maintained by this map

public class FastStringObjectMap<V> extends Object
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

    Constructors
    Constructor
    Description
    FastStringObjectMap(int initialCapacity, Class<V> c)
    Constructs a new map with the specified initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the map contains the specified key.
    get(String key)
    Returns the value associated with the specified key, or null if not found.
    Returns an array of all keys in the map.
    void
    put(String key, V value)
    Associates the specified value with the specified key in the map.
    Removes the mapping for the specified key from this map if present.
    int
    Returns the number of key-value mappings in the map.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FastStringObjectMap

      public FastStringObjectMap(int initialCapacity, Class<V> c)
      Constructs a new map with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity
  • Method Details

    • get

      public V get(String key)
      Returns the value associated with the specified key, or null if not found.
      Parameters:
      key - the key
      Returns:
      the associated value, or null if the key is not present
    • put

      public void put(String key, V value)
      Associates the specified value with the specified key in the map. If the key already exists, its value will be overwritten.
      Parameters:
      key - the key
      value - the value
    • containsKey

      public boolean containsKey(String key)
      Checks if the map contains the specified key.
      Parameters:
      key - the key to check
      Returns:
      true if the key is present, false otherwise
    • keys

      public String[] 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

      public V remove(String key)
      Removes the mapping for the specified key from this map if present.
      Parameters:
      key - the key whose mapping is to be removed
      Returns:
      the previous value associated with the key, or null if none
    • size

      public int size()
      Returns the number of key-value mappings in the map.
      Returns:
      the size of the map