Class GSetByHashMap<K,E extends K>

java.lang.Object
org.apache.hadoop.util.GSetByHashMap<K,E>
All Implemented Interfaces:
Iterable<E>, GSet<K,E>

@Private public class GSetByHashMap<K,E extends K> extends Object implements GSet<K,E>
A GSet implementation by HashMap.
  • Constructor Details

    • GSetByHashMap

      public GSetByHashMap(int initialCapacity, float loadFactor)
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface GSet<K,E extends K>
      Returns:
      The size of this set.
    • contains

      public boolean contains(K k)
      Description copied from interface: GSet
      Does this set contain an element corresponding to the given key?
      Specified by:
      contains in interface GSet<K,E extends K>
      Parameters:
      k - The given key.
      Returns:
      true if the given key equals to a stored element. Otherwise, return false.
    • get

      public E get(K k)
      Description copied from interface: GSet
      Return the stored element which is equal to the given key. This operation is similar to Map.get(Object).
      Specified by:
      get in interface GSet<K,E extends K>
      Parameters:
      k - The given key.
      Returns:
      The stored element if it exists. Otherwise, return null.
    • put

      public E put(E element)
      Description copied from interface: GSet
      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.
      Specified by:
      put in interface GSet<K,E extends K>
      Parameters:
      element - The element being put.
      Returns:
      the previous stored element if there is any. Otherwise, return null.
    • remove

      public E remove(K k)
      Description copied from interface: GSet
      Remove the element corresponding to the given key. This operation is similar to Map.remove(Object).
      Specified by:
      remove in interface GSet<K,E extends K>
      Parameters:
      k - The key of the element being removed.
      Returns:
      If such element exists, return it. Otherwise, return null.
    • iterator

      public Iterator<E> iterator()
      Specified by:
      iterator in interface Iterable<K>
    • clear

      public void clear()
      Description copied from interface: GSet
      Clear the set.
      Specified by:
      clear in interface GSet<K,E extends K>
    • values

      public Collection<E> values()
      Description copied from interface: GSet
      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.
      Specified by:
      values in interface GSet<K,E extends K>
      Returns:
      the collection of values.