public class NonEmptySet<T>
An immutable ordered non-empty set.
public T head()
Returns the first element of the set.
public boolean isEmpty()
@NotNull public java.util.Iterator<T> iterator()
public void forEach(@NotNull java.util.function.Consumer<? super T> action)
@NotNull public java.util.stream.Stream<T> stream()
@NotNull public java.util.stream.Stream<T> parallelStream()
@NotNull public java.util.Spliterator<T> spliterator()
public boolean equals(@Nullable java.lang.Object other)
public int hashCode()
@NotNull public java.lang.String toString()
public int getSize()
public boolean contains(java.lang.Object element)
public boolean containsAll(@NotNull java.util.Collection<? extends java.lang.Object> elements)
@JvmStatic @NotNull public static <T> NonEmptySet<T> of(T element)
Returns a singleton set containing element
. This behaves the same as Collections.singleton but returns a
class NonEmptySet
for the extra type-safety.
element
,
Collections.singleton,
class NonEmptySet
@JvmStatic @NotNull public static <T> NonEmptySet<T> of(T first, T second, @NotNull T... rest)
Returns a non-empty set containing the given elements, minus duplicates, in the order each was specified.
@JvmStatic @NotNull public static <T> NonEmptySet<T> copyOf(@NotNull java.util.Collection<? extends T> elements)
Returns a non-empty set containing each of elements
, minus duplicates, in the order each appears first in
the source collection.