Class IntegerMap<T>

java.lang.Object
com.comphenix.protocol.collections.IntegerMap<T>

public class IntegerMap<T> extends Object
Represents a very quick integer-based lookup map, with a fixed key space size.

Integers must be non-negative.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new integer map with a default capacity.
    IntegerMap(int initialCapacity)
    Construct a new integer map with a given capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    containsKey(int key)
    Determine if the given key exists in the map.
    protected void
    ensureCapacity(int key)
    Resize the backing array to fit the given key.
    get(int key)
    Retrieve the value associated with a given key.
    put(int key, T value)
    Associate an integer key with the given value.
    remove(int key)
    Remove an association from the map.
    int
    Retrieve the number of mappings in this map.
    Convert the current map to an Integer map.

    Methods inherited from class java.lang.Object

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

    • IntegerMap

      public IntegerMap()
      Construct a new integer map with a default capacity.
    • IntegerMap

      public IntegerMap(int initialCapacity)
      Construct a new integer map with a given capacity.
      Parameters:
      initialCapacity - - the capacity.
  • Method Details

    • put

      public T put(int key, T value)
      Associate an integer key with the given value.
      Parameters:
      key - - the integer key. Cannot be negative.
      value - - the value. Cannot be NULL.
      Returns:
      The previous association, or NULL if not found.
    • remove

      public T remove(int key)
      Remove an association from the map.
      Parameters:
      key - - the key of the association to remove.
      Returns:
      The old associated value, or NULL.
    • ensureCapacity

      protected void ensureCapacity(int key)
      Resize the backing array to fit the given key.
      Parameters:
      key - - the key.
    • size

      public int size()
      Retrieve the number of mappings in this map.
      Returns:
      The number of mapping.
    • get

      public T get(int key)
      Retrieve the value associated with a given key.
      Parameters:
      key - - the key.
      Returns:
      The value, or NULL if not found.
    • containsKey

      public boolean containsKey(int key)
      Determine if the given key exists in the map.
      Parameters:
      key - - the key to check.
      Returns:
      TRUE if it does, FALSE otherwise.
    • toMap

      public Map<Integer,Object> toMap()
      Convert the current map to an Integer map.
      Returns:
      The Integer map.