Class HashSet<E>

All Implemented Interfaces:
Iterable<E>, Set<E>, Traversable<E>, Iterable<E>

public class HashSet<E> extends AbstractSet<E>
HashSet is an implementation of Set backed by a HashMap.
  • Field Details

  • Constructor Details

    • HashSet

      private HashSet()
    • HashSet

      private HashSet(CompactHashMap<E,E> compactHashMap)
  • Method Details

    • factory

      @NotNull public static <E> @NotNull BuilderFactory<E,HashSet<E>> factory()
    • empty

      @NotNull public static <E> @NotNull HashSet<E> empty()
    • keyFunction

      private KeyFunction<E,E> keyFunction()
    • add

      @NotNull public @NotNull HashSet<E> add(E value)
      Description copied from interface: Set
      Returns a set that adds the specified value if it doesn't already exist in this set.
    • remove

      @NotNull public @NotNull HashSet<E> remove(E value)
      Description copied from interface: Set
      Removes the specified value from the set if it exists.
    • contains

      public boolean contains(E value)
      Description copied from interface: Set
      Returns true if the value exists in this set.
    • size

      public int size()
      Description copied from interface: Traversable
      Returns the size of the collection.

      Warning: infinite collections are possible, as are collections that require traversal to calculate the size.

      Specified by:
      size in interface Traversable<E>
      Overrides:
      size in class AbstractTraversable<E>
    • forEach

      public <U> void forEach(@NotNull @NotNull Function<E,U> f)
      Description copied from interface: Traversable
      All collection methods can be built upon this forEach definition.
      Specified by:
      forEach in interface Traversable<E>
      Overrides:
      forEach in class AbstractIterable<E>
    • iterator

      @NotNull public @NotNull Iterator<E> iterator()