Class EmptyHashSet<T>

java.lang.Object
org.javimmutable.collections.common.AbstractSet<T>
org.javimmutable.collections.hash.EmptyHashSet<T>
All Implemented Interfaces:
Serializable, Iterable<T>, ICollection<T>, InvariantCheckable, ISet<T>, IStreamable<T>, Mapped<T,T>, SplitableIterable<T>

public class EmptyHashSet<T> extends AbstractSet<T> implements Serializable
See Also:
  • Constructor Details

    • EmptyHashSet

      public EmptyHashSet()
  • Method Details

    • instance

      public static <T> EmptyHashSet<T> instance()
    • emptyMutableSet

      protected Set<T> emptyMutableSet()
      Description copied from class: AbstractSet
      Implemented by derived classes to create a new empty Set
      Specified by:
      emptyMutableSet in class AbstractSet<T>
    • insert

      @Nonnull public ISet<T> insert(@Nonnull T value)
      Description copied from interface: ISet
      Adds the single value to the Set.
      Specified by:
      insert in interface ICollection<T>
      Specified by:
      insert in interface ISet<T>
      Returns:
      instance of set containing the value
    • contains

      public boolean contains(@Nullable T value)
      Description copied from interface: ISet
      Determines if the Set contains the specified value.
      Specified by:
      contains in interface ISet<T>
      Returns:
      true if the Set contains the value
    • delete

      @Nonnull public ISet<T> delete(T value)
      Description copied from interface: ISet
      Removes the value from the Set. Has no effect if the value is not in the Set.
      Specified by:
      delete in interface ISet<T>
      Returns:
      instance of set without the value
    • deleteAll

      @Nonnull public ISet<T> deleteAll(@Nonnull Iterable<? extends T> other)
      Description copied from interface: ISet
      Removes all values of other from the Set. Has no effect if none of the values are in the Set
      Specified by:
      deleteAll in interface ISet<T>
      Overrides:
      deleteAll in class AbstractSet<T>
      Returns:
      instance of set without the values
    • deleteAll

      @Nonnull public ISet<T> deleteAll(@Nonnull Iterator<? extends T> other)
      Description copied from interface: ISet
      Removes all values of other from the Set. Has no effect if none of the values are in the Set
      Specified by:
      deleteAll in interface ISet<T>
      Returns:
      instance of set without the values
    • union

      @Nonnull public ISet<T> union(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Adds all values from other to the Set.
      Specified by:
      union in interface ISet<T>
      Parameters:
      values - source of values to add
      Returns:
      instance of set containing the values
    • intersection

      @Nonnull public ISet<T> intersection(@Nonnull Iterable<? extends T> other)
      Description copied from interface: ISet
      Removes all values from the Set that are not contained in the other collection.
      Specified by:
      intersection in interface ISet<T>
      Overrides:
      intersection in class AbstractSet<T>
      Returns:
      instance of set with unmatched values removed
    • intersection

      @Nonnull public ISet<T> intersection(@Nonnull ISet<? extends T> other)
      Description copied from interface: ISet
      Removes all values from the Set that are not contained in the other collection.
      Specified by:
      intersection in interface ISet<T>
      Overrides:
      intersection in class AbstractSet<T>
      Returns:
      instance of set with unmatched values removed
    • intersection

      @Nonnull public ISet<T> intersection(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Removes all values from the Set that are not contained in the other collection.
      Specified by:
      intersection in interface ISet<T>
      Returns:
      instance of set with unmatched values removed
    • intersection

      @Nonnull public ISet<T> intersection(@Nonnull Set<? extends T> other)
      Description copied from interface: ISet
      Removes all values from the Set that are not contained in the other collection.
      Specified by:
      intersection in interface ISet<T>
      Returns:
      instance of set with unmatched values removed
    • size

      public int size()
      Specified by:
      size in interface ICollection<T>
      Returns:
      number of values in the collection
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface ICollection<T>
      Returns:
      true only if collection contains no values
    • deleteAll

      @Nonnull public ISet<T> deleteAll()
      Specified by:
      deleteAll in interface ICollection<T>
      Specified by:
      deleteAll in interface ISet<T>
      Returns:
      an equivalent collection with no values
    • checkInvariants

      public void checkInvariants()
      Description copied from interface: InvariantCheckable
      Checks invariants of implementing class.
      Specified by:
      checkInvariants in interface InvariantCheckable
    • iterator

      @Nonnull public SplitableIterator<T> iterator()
      Description copied from interface: IStreamable
      Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator. This is necessary to allow composition of new objects from methods like keys() and values().
      Specified by:
      iterator in interface IStreamable<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface SplitableIterable<T>
    • getSpliteratorCharacteristics

      public int getSpliteratorCharacteristics()
      Specified by:
      getSpliteratorCharacteristics in interface IStreamable<T>
      Returns:
      characteristics value used when creating Spliterators