Class WeakHashSet

All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, Set

public class WeakHashSet extends HashSet
A weak HashSet. An element stored in the WeakHashSet might be garbage collected, if there is no strong reference to this element.
See Also:
  • Constructor Details

    • WeakHashSet

      public WeakHashSet()
  • Method Details

    • iterator

      public Iterator iterator()
      Returns an iterator over the elements in this set. The elements are returned in no particular order.
      Specified by:
      iterator in interface Collection
      Specified by:
      iterator in interface Iterable
      Specified by:
      iterator in interface Set
      Overrides:
      iterator in class HashSet
      Returns:
      an Iterator over the elements in this set.
    • contains

      public boolean contains(Object o)
      Returns true if this set contains the specified element.
      Specified by:
      contains in interface Collection
      Specified by:
      contains in interface Set
      Overrides:
      contains in class HashSet
      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(Object o)
      Adds the specified element to this set if it is not already present.
      Specified by:
      add in interface Collection
      Specified by:
      add in interface Set
      Overrides:
      add in class HashSet
      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 given element from this set if it is present.
      Specified by:
      remove in interface Collection
      Specified by:
      remove in interface Set
      Overrides:
      remove in class HashSet
      Parameters:
      o - object to be removed from this set, if present.
      Returns:
      true if the set contained the specified element.