Class SmallSet<E>

  • Type Parameters:
    E - The type of elements to be contained in this small set.
    All Implemented Interfaces:
    Iterable<E>, Collection<E>, Set<E>

    public final class SmallSet<E>
    extends AbstractSet<E>
    A small set of values. This set implementation is optimized to use as little memory as possible in the case where there zero or one elements.

    In addition, any normalization of elements is delayed until the second element is added (normalization may be triggered by invoking Object.hashCode() or Object.equals(Object).

    • Constructor Detail

      • SmallSet

        public SmallSet()
        Creates a new small set which is initially empty.
      • SmallSet

        public SmallSet​(Collection<? extends E> c)
        Creates a new small set from the provided collection.
        Parameters:
        c - the collection whose elements are to be placed into this set
        Throws:
        NullPointerException - if the specified collection is null
      • SmallSet

        public SmallSet​(int initialCapacity)
        Creates a new small set with an initial capacity.
        Parameters:
        initialCapacity - The capacity of the set