GSetByHashMap (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: GSetByHashMap

Package org.apache.hadoop.util

# 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`.

- ## Field Summary

  ### Fields inherited from interface org.apache.hadoop.util.GSet

  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GSetByHashMap(int initialCapacity, float loadFactor)`

- ## Method Summary

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

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## 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.