Interface ImmutableSet<E extends @Nullable Object>

Type Parameters:
E - the type of elements contained in the set. The set is covariant on its element type.
All Superinterfaces:
ImmutableCollection<E>, Iterable<E>
All Known Subinterfaces:
PersistentSet<E>

public interface ImmutableSet<E extends @Nullable Object> extends ImmutableCollection<E>

A generic immutable unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the immutable set.

Modification operations are supported through the PersistentSet interface.

Implementors of this interface take responsibility to be immutable. Once constructed they must contain the same elements in the same order.

  • Method Details

    • from

      static <T extends @Nullable Object> ImmutableSet<T> from(Iterable<T> iterable)

      Returns an immutable set of all elements of the specified collection.

      If the specified collection is already an immutable set, returns it as is.

      Elements of the returned set are iterated in the same order as in the specified collection.

    • from

      static <T extends @Nullable Object> ImmutableSet<T> from(T[] array)

      Returns an immutable set of all elements of the specified array.

      Elements of the returned set are iterated in the same order as in the specified array.

    • from

      static <T extends @Nullable Object> ImmutableSet<T> from(Stream<? extends T> stream)

      Returns an immutable set of all elements of the specified sequence.

      Elements of the returned set are iterated in the same order as in the specified sequence.

    • from

      static ImmutableSet<Character> from(CharSequence chars)

      Returns an immutable set of all characters.

      Elements of the returned set are iterated in the same order as in the specified char sequence.