Interface PSet<E>
- Type Parameters:
E- the type of elements maintained by this set
- All Superinterfaces:
Iterable<E>
Persistent (functional) Set.
- Author:
- Evgeny Mandrikov
-
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanisEmpty()static <E> PSet<E>of()Returns a persistent set containing zero elements.static <E> PSet<E>of(E e1) Returns a persistent set containing one element.static <E> PSet<E>of(E e1, E e2) Returns a persistent set containing two elements.static <E> PSet<E>of(E e1, E e2, E e3) Returns a persistent set containing three elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4) Returns a persistent set containing four elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4, E e5) Returns a persistent set containing five elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4, E e5, E e6) Returns a persistent set containing six elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) Returns a persistent set containing seven elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) Returns a persistent set containing eight elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) Returns a persistent set containing nine elements.static <E> PSet<E>of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) Returns a persistent set containing ten elements.stream()toString()The string representation consists of a list of elements in the ascending order of hash codes.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
add
- Returns:
- new set with added element, or this if element already in the set
-
remove
- Returns:
- new set with removed element, or this if set does not contain given element
-
contains
- Returns:
- true if this set contains the specified element
-
isEmpty
boolean isEmpty()- Returns:
- true if this set contains no elements
-
toString
String toString()The string representation consists of a list of elements in the ascending order of hash codes. If two elements have same hash code, then their relative order is arbitrary, but stable. -
stream
- Returns:
- stream of the set's elements
-
of
Returns a persistent set containing zero elements.- Type Parameters:
E- thePSet's element type- Returns:
- an empty
PSet
-
of
Returns a persistent set containing one element.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the single element- Returns:
- a
PSetcontaining the specified element
-
of
Returns a persistent set containing two elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing three elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing four elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing five elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth elemente5- the fifth element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing six elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth elemente5- the fifth elemente6- the sixth element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing seven elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth elemente5- the fifth elemente6- the sixth elemente7- the seventh element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing eight elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth elemente5- the fifth elemente6- the sixth elemente7- the seventh elemente8- the eighth element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing nine elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth elemente5- the fifth elemente6- the sixth elemente7- the seventh elemente8- the eighth elemente9- the ninth element- Returns:
- a
PSetcontaining the specified elements
-
of
Returns a persistent set containing ten elements.- Type Parameters:
E- thePSet's element type- Parameters:
e1- the first elemente2- the second elemente3- the third elemente4- the fourth elemente5- the fifth elemente6- the sixth elemente7- the seventh elemente8- the eighth elemente9- the ninth elemente10- the tenth element- Returns:
- a
PSetcontaining the specified elements
-