Class BasedHashSet<E>

java.lang.Object
com.gigaspaces.internal.utils.collections.BasedHashSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
ConcurrentHashSet, CopyOnUpdateSet

public class BasedHashSet<E> extends Object implements Set<E>
Provides a base for any Map based HashSet implementation.
Since:
7.0
Author:
Guy Korland
  • Constructor Details

    • BasedHashSet

      public BasedHashSet(Map<E,Object> map)
      Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
  • Method Details

    • iterator

      public Iterator<E> iterator()
      Returns an iterator over the elements in this set. The elements are returned in no particular order.
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface Set<E>
      Returns:
      an Iterator over the elements in this set.
      See Also:
      • ConcurrentModificationException
    • size

      public int size()
      Returns the number of elements in this set (its cardinality).
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface Set<E>
      Returns:
      the number of elements in this set (its cardinality).
    • isEmpty

      public boolean isEmpty()
      Returns true if this set contains no elements.
      Specified by:
      isEmpty in interface Collection<E>
      Specified by:
      isEmpty in interface Set<E>
      Returns:
      true if this set contains no elements.
    • contains

      public boolean contains(Object o)
      Returns true if this set contains the specified element.
      Specified by:
      contains in interface Collection<E>
      Specified by:
      contains in interface Set<E>
      Parameters:
      o - element whose presence in this set is to be tested.
      Returns:
      true if this set contains the specified element.
    • add

      public boolean add(E o)
      Adds the specified element to this set if it is not already present.
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface Set<E>
      Parameters:
      o - element to be added to this set.
      Returns:
      true if the set did not already contain the specified element.
    • remove

      public boolean remove(Object o)
      Removes the specified element from this set if it is present.
      Specified by:
      remove in interface Collection<E>
      Specified by:
      remove in interface Set<E>
      Parameters:
      o - object to be removed from this set, if present.
      Returns:
      true if the set contained the specified element.
    • clear

      public void clear()
      Removes all of the elements from this set.
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface Set<E>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface Set<E>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<E>
      Specified by:
      containsAll in interface Set<E>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<E>
      Specified by:
      removeAll in interface Set<E>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<E>
      Specified by:
      retainAll in interface Set<E>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<E>
      Specified by:
      toArray in interface Set<E>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<E>
      Specified by:
      toArray in interface Set<E>
    • toString

      public String toString()
      Overrides:
      toString in class Object