Interface GSet<K,E extends K>

Type Parameters:
K - The type of the keys.
E - The type of the elements, which must be a subclass of the keys.
All Superinterfaces:
Iterable<E>
All Known Implementing Classes:
GSetByHashMap, LightWeightCache, LightWeightGSet, LightWeightResizableGSet

@Private public interface GSet<K,E extends K> extends Iterable<E>
A GSet is set, which supports the get(Object) operation. The get(Object) operation uses a key to lookup an element. Null element is not supported.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the set.
    boolean
    contains(K key)
    Does this set contain an element corresponding to the given key?
    get(K key)
    Return the stored element which is equal to the given key.
    put(E element)
    Add/replace an element.
    remove(K key)
    Remove the element corresponding to the given key.
    int
     
    Returns a Collection view of the values contained in this set.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Field Details

    • LOG

      static final org.slf4j.Logger LOG
  • Method Details

    • size

      int size()
      Returns:
      The size of this set.
    • contains

      boolean contains(K key)
      Does this set contain an element corresponding to the given key?
      Parameters:
      key - The given key.
      Returns:
      true if the given key equals to a stored element. Otherwise, return false.
      Throws:
      NullPointerException - if key == null.
    • get

      E get(K key)
      Return the stored element which is equal to the given key. This operation is similar to Map.get(Object).
      Parameters:
      key - The given key.
      Returns:
      The stored element if it exists. Otherwise, return null.
      Throws:
      NullPointerException - if key == null.
    • put

      E put(E element)
      Add/replace an element. If the element does not exist, add it to the set. Otherwise, replace the existing element. Note that this operation is similar to Map.put(Object, Object) but is different from Set.add(Object) which does not replace the existing element if there is any.
      Parameters:
      element - The element being put.
      Returns:
      the previous stored element if there is any. Otherwise, return null.
      Throws:
      NullPointerException - if element == null.
    • remove

      E remove(K key)
      Remove the element corresponding to the given key. This operation is similar to Map.remove(Object).
      Parameters:
      key - The key of the element being removed.
      Returns:
      If such element exists, return it. Otherwise, return null.
      Throws:
      NullPointerException - if key == null.
    • clear

      void clear()
      Clear the set.
    • values

      Collection<E> values()
      Returns a Collection view of the values contained in this set. The collection is backed by the set, so changes to the set are reflected in the collection, and vice-versa.
      Returns:
      the collection of values.