Class HashSet<E>

  • All Implemented Interfaces:
    Iterable<E>, Set<E>, Traversable<E>, java.lang.Iterable<E>

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

      • HashSet

        private HashSet()
    • Method Detail

      • empty

        @NotNull
        public static <E> @NotNull HashSet<E> empty()
      • 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>
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<E> iterator()