Class Components.PoolingIndex<K,V>

java.lang.Object
org.jgrapes.core.Components.PoolingIndex<K,V>
Type Parameters:
K - the key type
V - the value type
Enclosing class:
Components

public static class Components.PoolingIndex<K,V> extends Object
An index of pooled items.

Each key is associated with a set of values. Values can be added or retrieved from the set.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add(K key, V value)
    Adds the value to the pool of values associated with the key.
    void
    Remove all entries.
    boolean
    Checks if the key is in the index.
    boolean
    Checks if the index is empty.
    Returns all keys.
    int
    Returns the number of keys in the index.
    poll(K key)
    Retrives and removes an item from the pool associated with the key.
    remove(K key, V value)
    Removes the given value from the pool associated with the given key.
    remove(V value)
    Removes the value from the first pool in which it is found.
    void
    removeAll(K key)
    Removes all values associated with the key.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • clear

      public void clear()
      Remove all entries.
    • containsKey

      public boolean containsKey(Object key)
      Checks if the key is in the index.
      Parameters:
      key - the key
      Returns:
      true, if successful
    • isEmpty

      public boolean isEmpty()
      Checks if the index is empty.
      Returns:
      true, if is empty
    • keySet

      public Set<K> keySet()
      Returns all keys.
      Returns:
      the sets the
    • add

      public V add(K key, V value)
      Adds the value to the pool of values associated with the key.
      Parameters:
      key - the key
      value - the value
      Returns:
      the v
    • poll

      public V poll(K key)
      Retrives and removes an item from the pool associated with the key.
      Parameters:
      key - the key
      Returns:
      the removed item or null if the pool is empty
    • removeAll

      public void removeAll(K key)
      Removes all values associated with the key.
      Parameters:
      key - the key
    • remove

      public V remove(K key, V value)
      Removes the given value from the pool associated with the given key.
      Parameters:
      key - the key
      value - the value
      Returns:
      the v
    • remove

      public V remove(V value)
      Removes the value from the first pool in which it is found.
      Parameters:
      value - the value
      Returns:
      the value or null if the value is not found
    • keysSize

      public int keysSize()
      Returns the number of keys in the index.
      Returns:
      the numer of keys