Class DenseIntMap<T>

java.lang.Object
io.github.jbellis.jvector.util.DenseIntMap<T>

public class DenseIntMap<T> extends Object
A map (but not a Map) of int -> T where the int keys are dense-ish and start at zero, but the size of the map is not known in advance. This provides fast, concurrent updates and minimizes contention when the map is resized.

"Dense-ish" means that space is allocated for all keys from 0 to the highest key, but it is valid to have gaps in the keys. The value associated with "gap" keys is null.

  • Constructor Details

    • DenseIntMap

      public DenseIntMap(int initialSize)
  • Method Details

    • put

      public void put(int key, T value)
      Parameters:
      key - ordinal
    • size

      public int size()
      Returns:
      number of items that have been added
    • get

      public T get(int key)
      Parameters:
      key - ordinal
      Returns:
      the value of the key, or null if not set
    • remove

      public T remove(int key)
      Returns:
      the former value of the key, or null if it was not set
    • containsKey

      public boolean containsKey(int key)
    • entrySet

      public Set<Map.Entry<Integer,T>> entrySet()
    • keySet

      public Set<Integer> keySet()
    • getNodesIterator

      public NodesIterator getNodesIterator()