Class THashSet<E>

Type Parameters:
E -
All Implemented Interfaces:
TSerializable, TCloneable, TIterable<E>, TCollection<E>, TSet<E>
Direct Known Subclasses:
TLinkedHashSet

public class THashSet<E> extends TAbstractSet<E> implements TCloneable, TSerializable
  • Constructor Details

    • THashSet

      public THashSet()
      Constructs a new empty instance of HashSet.
    • THashSet

      public THashSet(int capacity)
      Constructs a new instance of HashSet with the specified capacity.
      Parameters:
      capacity - the initial capacity of this HashSet.
    • THashSet

      public THashSet(int capacity, float loadFactor)
      Constructs a new instance of HashSet with the specified capacity and load factor.
      Parameters:
      capacity - the initial capacity.
      loadFactor - the initial load factor.
    • THashSet

      public THashSet(TCollection<? extends E> collection)
      Constructs a new instance of HashSet containing the unique elements in the specified collection.
      Parameters:
      collection - the collection of elements to add.
  • Method Details

    • add

      public boolean add(E object)
      Adds the specified object to this HashSet if not already present.
      Specified by:
      add in interface TCollection<E>
      Overrides:
      add in class TAbstractCollection<E>
      Parameters:
      object - the object to add.
      Returns:
      true when this HashSet did not already contain the object, false otherwise
    • clear

      public void clear()
      Removes all elements from this HashSet, leaving it empty.
      Specified by:
      clear in interface TCollection<E>
      Overrides:
      clear in class TAbstractCollection<E>
      See Also:
    • clone0

      public TObject clone0()
      Returns a new HashSet with the same elements and size as this HashSet.
      Returns:
      a shallow copy of this HashSet.
      See Also:
    • contains

      public boolean contains(Object object)
      Searches this HashSet for the specified object.
      Specified by:
      contains in interface TCollection<E>
      Overrides:
      contains in class TAbstractCollection<E>
      Parameters:
      object - the object to search for.
      Returns:
      true if object is an element of this HashSet, false otherwise.
    • isEmpty

      public boolean isEmpty()
      Returns true if this HashSet has no elements, false otherwise.
      Specified by:
      isEmpty in interface TCollection<E>
      Overrides:
      isEmpty in class TAbstractCollection<E>
      Returns:
      true if this HashSet has no elements, false otherwise.
      See Also:
    • iterator

      public TIterator<E> iterator()
      Returns an Iterator on the elements of this HashSet.
      Specified by:
      iterator in interface TIterable<E>
      Returns:
      an Iterator on the elements of this HashSet.
      See Also:
    • remove

      public boolean remove(Object object)
      Removes the specified object from this HashSet.
      Specified by:
      remove in interface TCollection<E>
      Overrides:
      remove in class TAbstractCollection<E>
      Parameters:
      object - the object to remove.
      Returns:
      true if the object was removed, false otherwise.
    • size

      public int size()
      Returns the number of elements in this HashSet.
      Specified by:
      size in interface TCollection<E>
      Returns:
      the number of elements in this HashSet.
    • clone

      public Object clone()
      Overrides:
      clone in class TObject
    • newHashSet

      public static <T> THashSet<T> newHashSet(int size)