T
- Component typepublic final class TreeSet<T> extends Object implements Kind1<TreeSet<?>,T>, SortedSet<T>, Serializable
λ.Memoized
Modifier and Type | Method and Description |
---|---|
TreeSet<T> |
add(T element)
Add the given element to this set, if it is not already contained.
|
TreeSet<T> |
addAll(Iterable<? extends T> elements)
Adds all of the given elements to this set, if not already contained.
|
static <T> Collector<T,ArrayList<T>,TreeSet<T>> |
collector()
Returns a
Collector which may be used in conjunction with
Stream.collect(java.util.stream.Collector) to obtain a TreeSet . |
Comparator<T> |
comparator()
Returns the underlying comparator which defines the order of the elements contained in this set.
|
boolean |
contains(T element)
Shortcut for
exists(e -> Objects.equals(e, element)) , tests if the given element is contained. |
TreeSet<T> |
diff(Set<? extends T> elements)
Calculates the difference between this set and another set.
|
TreeSet<T> |
distinct()
Returns a new version of this which contains no duplicates.
|
TreeSet<T> |
distinctBy(Comparator<? super T> comparator)
Returns a new version of this which contains no duplicates.
|
<U> TreeSet<T> |
distinctBy(Function<? super T,? extends U> keyExtractor)
Returns a new version of this which contains no duplicates.
|
TreeSet<T> |
drop(long n)
Drops the first n elements of this or all elements, if this length < n.
|
TreeSet<T> |
dropRight(long n)
Drops the last n elements of this or all elements, if this length < n.
|
TreeSet<T> |
dropUntil(Predicate<? super T> predicate)
Drops elements until the predicate holds for the current element.
|
TreeSet<T> |
dropWhile(Predicate<? super T> predicate)
Drops elements while the predicate holds for the current element.
|
static <T extends Comparable<? super T>> |
empty() |
static <T> TreeSet<T> |
empty(Comparator<? super T> comparator) |
boolean |
equals(Object o)
Clarifies that values have a proper equals() method implemented.
|
static <T> TreeSet<T> |
fill(Comparator<? super T> comparator,
int n,
Supplier<? extends T> s)
Returns a TreeSet containing
n values supplied by a given Supplier s . |
static <T extends Comparable<? super T>> |
fill(int n,
Supplier<? extends T> s)
Returns a TreeSet containing
n values supplied by a given Supplier s . |
TreeSet<T> |
filter(Predicate<? super T> predicate)
Returns a new traversable consisting of all elements which satisfy the given predicate.
|
<U> TreeSet<U> |
flatMap(Comparator<? super U> comparator,
Function<? super T,? extends Iterable<? extends U>> mapper)
Same as
SortedSet.flatMap(Function) but using a specific comparator for values of the codomain of the given
mapper . |
<U> TreeSet<U> |
flatMap(Function<? super T,? extends Iterable<? extends U>> mapper)
FlatMaps this Traversable.
|
<U> U |
foldRight(U zero,
BiFunction<? super T,? super U,? extends U> f)
Accumulates the elements of this Traversable by successively calling the given function
f from the right,
starting with a value zero of type B. |
<C> Map<C,TreeSet<T>> |
groupBy(Function<? super T,? extends C> classifier)
Groups this elements by classifying the elements.
|
Iterator<TreeSet<T>> |
grouped(long size)
Groups this
Traversable into fixed size blocks. |
boolean |
hasDefiniteSize()
Checks if this Traversable is known to have a finite size.
|
int |
hashCode()
Clarifies that values have a proper hashCode() method implemented.
|
T |
head()
Returns the first element of a non-empty Traversable.
|
Option<T> |
headOption()
Returns the first element of a non-empty Traversable as
Option . |
TreeSet<T> |
init()
Dual of Traversable.tail(), returning all elements except the last.
|
Option<TreeSet<T>> |
initOption()
Dual of Traversable.tailOption(), returning all elements except the last as
Option . |
TreeSet<T> |
intersect(Set<? extends T> elements)
Computes the intersection between this set and another set.
|
boolean |
isEmpty()
Checks if this Traversable is empty.
|
boolean |
isTraversableAgain()
Checks if this Traversable can be repeatedly traversed.
|
Iterator<T> |
iterator()
An iterator by means of head() and tail().
|
int |
length()
Computes the number of elements of this Traversable.
|
<U> TreeSet<U> |
map(Comparator<? super U> comparator,
Function<? super T,? extends U> mapper)
Same as
SortedSet.map(Function) but using a specific comparator for values of the codomain of the given
mapper . |
<U> TreeSet<U> |
map(Function<? super T,? extends U> mapper)
Maps the elements of this
Traversable to elements of a new type preserving their order, if any. |
Option<T> |
max()
Calculates the maximum of this elements according to their natural order.
|
Option<T> |
min()
Calculates the minimum of this elements according to their natural order.
|
static <T> TreeSet<T> |
narrow(TreeSet<? extends T> treeSet)
Narrows a widened
TreeSet<? extends T> to TreeSet<T>
by performing a type safe-cast. |
static <T> TreeSet<T> |
of(Comparator<? super T> comparator,
T... values) |
static <T> TreeSet<T> |
of(Comparator<? super T> comparator,
T value) |
static <T extends Comparable<? super T>> |
of(T... values) |
static <T extends Comparable<? super T>> |
of(T value)
|
static TreeSet<Boolean> |
ofAll(boolean[] array)
Creates a TreeSet based on the elements of a boolean array.
|
static TreeSet<Byte> |
ofAll(byte[] array)
Creates a TreeSet based on the elements of a byte array.
|
static TreeSet<Character> |
ofAll(char[] array)
Creates a TreeSet based on the elements of a char array.
|
static <T> TreeSet<T> |
ofAll(Comparator<? super T> comparator,
Iterable<? extends T> values) |
static TreeSet<Double> |
ofAll(double[] array)
Creates a TreeSet based on the elements of a double array.
|
static TreeSet<Float> |
ofAll(float[] array)
Creates a TreeSet based on the elements of a float array.
|
static TreeSet<Integer> |
ofAll(int[] array)
Creates a TreeSet based on the elements of an int array.
|
static <T extends Comparable<? super T>> |
ofAll(Iterable<? extends T> values) |
static TreeSet<Long> |
ofAll(long[] array)
Creates a TreeSet based on the elements of a long array.
|
static TreeSet<Short> |
ofAll(short[] array)
Creates a TreeSet based on the elements of a short array.
|
Tuple2<TreeSet<T>,TreeSet<T>> |
partition(Predicate<? super T> predicate)
Creates a partition of this
Traversable by splitting this elements in two in distinct tarversables
according to a predicate. |
TreeSet<T> |
peek(Consumer<? super T> action)
Performs the given
action on the first element if this is an eager implementation. |
static TreeSet<Character> |
range(char from,
char toExclusive) |
static TreeSet<Integer> |
range(int from,
int toExclusive)
Creates a TreeSet of int numbers starting from
from , extending to toExclusive - 1 . |
static TreeSet<Long> |
range(long from,
long toExclusive)
Creates a TreeSet of long numbers starting from
from , extending to toExclusive - 1 . |
static TreeSet<Character> |
rangeBy(char from,
char toExclusive,
int step) |
static TreeSet<Double> |
rangeBy(double from,
double toExclusive,
double step) |
static TreeSet<Integer> |
rangeBy(int from,
int toExclusive,
int step)
Creates a TreeSet of int numbers starting from
from , extending to toExclusive - 1 ,
with step . |
static TreeSet<Long> |
rangeBy(long from,
long toExclusive,
long step)
Creates a TreeSet of long numbers starting from
from , extending to toExclusive - 1 ,
with step . |
static TreeSet<Character> |
rangeClosed(char from,
char toInclusive) |
static TreeSet<Integer> |
rangeClosed(int from,
int toInclusive)
Creates a TreeSet of int numbers starting from
from , extending to toInclusive . |
static TreeSet<Long> |
rangeClosed(long from,
long toInclusive)
Creates a TreeSet of long numbers starting from
from , extending to toInclusive . |
static TreeSet<Character> |
rangeClosedBy(char from,
char toInclusive,
int step) |
static TreeSet<Double> |
rangeClosedBy(double from,
double toInclusive,
double step) |
static TreeSet<Integer> |
rangeClosedBy(int from,
int toInclusive,
int step)
Creates a TreeSet of int numbers starting from
from , extending to toInclusive ,
with step . |
static TreeSet<Long> |
rangeClosedBy(long from,
long toInclusive,
long step)
Creates a TreeSet of long numbers starting from
from , extending to toInclusive ,
with step . |
TreeSet<T> |
remove(T element)
Removes a specific element from this set, if present.
|
TreeSet<T> |
removeAll(Iterable<? extends T> elements)
Removes all of the given elements from this set, if present.
|
TreeSet<T> |
replace(T currentElement,
T newElement)
Replaces the first occurrence (if exists) of the given currentElement with newElement.
|
TreeSet<T> |
replaceAll(T currentElement,
T newElement)
Replaces all occurrences of the given currentElement with newElement.
|
TreeSet<T> |
retainAll(Iterable<? extends T> elements)
Keeps all occurrences of the given elements from this.
|
TreeSet<T> |
scan(T zero,
BiFunction<? super T,? super T,? extends T> operation)
Computes a prefix scan of the elements of the collection.
|
<U> Set<U> |
scanLeft(U zero,
BiFunction<? super U,? super T,? extends U> operation)
Produces a collection containing cumulative results of applying the
operator going left to right.
|
<U> Set<U> |
scanRight(U zero,
BiFunction<? super T,? super U,? extends U> operation)
Produces a collection containing cumulative results of applying the
operator going right to left.
|
Iterator<TreeSet<T>> |
sliding(long size)
Slides a window of a specific
size and step size 1 over this Traversable by calling
Traversable.sliding(long, long) . |
Iterator<TreeSet<T>> |
sliding(long size,
long step)
Slides a window of a specific
size and step size over this Traversable . |
Tuple2<TreeSet<T>,TreeSet<T>> |
span(Predicate<? super T> predicate)
Returns a tuple where the first element is the longest prefix of elements that satisfy the given
predicate and the second element is the remainder. |
String |
stringPrefix()
Returns the name of this Value type, which is used by toString().
|
static <T> TreeSet<T> |
tabulate(Comparator<? super T> comparator,
int n,
Function<? super Integer,? extends T> f)
Returns a TreeSet containing
n values of a given Function f
over a range of integer values from 0 to n - 1 . |
static <T extends Comparable<? super T>> |
tabulate(int n,
Function<? super Integer,? extends T> f)
Returns a TreeSet containing
n values of a given Function f
over a range of integer values from 0 to n - 1 . |
TreeSet<T> |
tail()
Drops the first element of a non-empty Traversable.
|
Option<TreeSet<T>> |
tailOption()
Drops the first element of a non-empty Traversable and returns an
Option . |
TreeSet<T> |
take(long n)
Takes the first n elements of this or all elements, if this length < n.
|
TreeSet<T> |
takeRight(long n)
Takes the last n elements of this or all elements, if this length < n.
|
TreeSet<T> |
takeUntil(Predicate<? super T> predicate)
Takes elements until the predicate holds for the current element.
|
TreeSet<T> |
takeWhile(Predicate<? super T> predicate)
Takes elements while the predicate holds for the current element.
|
TreeSet<T> |
toJavaSet()
Converts this Javaslang
Set to a java.util.Set while preserving characteristics
like insertion order (LinkedHashSet ) and sort order (SortedSet ). |
String |
toString()
Clarifies that values have a proper toString() method implemented.
|
<U> U |
transform(Function<? super TreeSet<T>,? extends U> f)
Transforms this
TreeSet . |
TreeSet<T> |
union(Set<? extends T> elements)
Adds all of the elements of
that set to this set, if not already present. |
<T1,T2> Tuple2<TreeSet<T1>,TreeSet<T2>> |
unzip(Function<? super T,Tuple2<? extends T1,? extends T2>> unzipper)
Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct
sets.
|
<T1,T2,T3> Tuple3<TreeSet<T1>,TreeSet<T2>,TreeSet<T3>> |
unzip3(Function<? super T,Tuple3<? extends T1,? extends T2,? extends T3>> unzipper)
Unzips this elements by mapping this elements to triples which are subsequently split into three distinct
sets.
|
<U> TreeSet<Tuple2<T,U>> |
zip(Iterable<? extends U> that)
Returns a traversable formed from this traversable and another Iterable collection by combining
corresponding elements in pairs.
|
<U> TreeSet<Tuple2<T,U>> |
zipAll(Iterable<? extends U> that,
T thisElem,
U thatElem)
Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in
pairs.
|
TreeSet<Tuple2<T,Long>> |
zipWithIndex()
Zips this traversable with its indices.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
apply, narrow, spliterator
average, containsAll, count, existsUnique, find, findLast, foldLeft, get, hash, isSingleValued, lastOption, maxBy, maxBy, minBy, minBy, mkString, mkString, mkString, narrow, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, size, sum
fold, reduce, reduceOption
corresponds, eq, exists, forAll, forEach, getOption, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, narrow, out, out, stderr, stdout, toArray, toCharSeq, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaOptional, toJavaSet, toJavaStream, toLeft, toLeft, toList, toMap, toOption, toQueue, toRight, toRight, toSet, toStack, toStream, toTree, toTry, toTry, toVector
andThen, arity, compose, curried, identity, lift, memoized, reversed, tupled
isMemoized
public static <T> Collector<T,ArrayList<T>,TreeSet<T>> collector()
Collector
which may be used in conjunction with
Stream.collect(java.util.stream.Collector)
to obtain a TreeSet
.T
- Component type of the List.public static <T extends Comparable<? super T>> TreeSet<T> empty()
public static <T> TreeSet<T> empty(Comparator<? super T> comparator)
public static <T> TreeSet<T> narrow(TreeSet<? extends T> treeSet)
TreeSet<? extends T>
to TreeSet<T>
by performing a type safe-cast. This is eligible because immutable/read-only
collections are covariant.
CAUTION: The underlying Comparator
might fail!
T
- Component type of the TreeSet
.treeSet
- A TreeSet
.treeSet
instance as narrowed type TreeSet<T>
.public static <T extends Comparable<? super T>> TreeSet<T> of(T value)
Function1
Function1
based on
Examples (w.l.o.g. referring to Function1):
// using a lambda expression
Function1<Integer, Integer> add1 = Function1.of(i -> i + 1);
// using a method reference (, e.g. Integer method(Integer i) { return i + 1; })
Function1<Integer, Integer> add2 = Function1.of(this::method);
// using a lambda reference
Function1<Integer, Integer> add3 = Function1.of(add1::apply);
Caution: Reflection loses type information of lambda references.
// type of a lambda expression
Type<?, ?> type1 = add1.getType(); // (Integer) -> Integer
// type of a method reference
Type<?, ?> type2 = add2.getType(); // (Integer) -> Integer
// type of a lambda reference
Type<?, ?> type3 = add3.getType(); // (Object) -> Object
public static <T> TreeSet<T> of(Comparator<? super T> comparator, T value)
@SafeVarargs public static <T extends Comparable<? super T>> TreeSet<T> of(T... values)
@SafeVarargs public static <T> TreeSet<T> of(Comparator<? super T> comparator, T... values)
public static <T> TreeSet<T> tabulate(Comparator<? super T> comparator, int n, Function<? super Integer,? extends T> f)
n
values of a given Function f
over a range of integer values from 0 to n - 1
.T
- Component type of the TreeSetcomparator
- The comparator used to sort the elementsn
- The number of elements in the TreeSetf
- The Function computing element valuesf(0),f(1), ..., f(n - 1)
NullPointerException
- if comparator
or f
are nullpublic static <T extends Comparable<? super T>> TreeSet<T> tabulate(int n, Function<? super Integer,? extends T> f)
n
values of a given Function f
over a range of integer values from 0 to n - 1
.
The underlying comparator is the natural comparator of T.T
- Component type of the TreeSetn
- The number of elements in the TreeSetf
- The Function computing element valuesf(0),f(1), ..., f(n - 1)
NullPointerException
- if f
is nullpublic static <T> TreeSet<T> fill(Comparator<? super T> comparator, int n, Supplier<? extends T> s)
n
values supplied by a given Supplier s
.T
- Component type of the TreeSetcomparator
- The comparator used to sort the elementsn
- The number of elements in the TreeSets
- The Supplier computing element valuesn
, where each element contains the result supplied by s
.NullPointerException
- if comparator
or s
are nullpublic static <T extends Comparable<? super T>> TreeSet<T> fill(int n, Supplier<? extends T> s)
n
values supplied by a given Supplier s
.
The underlying comparator is the natural comparator of T.T
- Component type of the TreeSetn
- The number of elements in the TreeSets
- The Supplier computing element valuesn
, where each element contains the result supplied by s
.NullPointerException
- if s
is nullpublic static <T extends Comparable<? super T>> TreeSet<T> ofAll(Iterable<? extends T> values)
public static <T> TreeSet<T> ofAll(Comparator<? super T> comparator, Iterable<? extends T> values)
public static TreeSet<Boolean> ofAll(boolean[] array)
array
- a boolean arraypublic static TreeSet<Byte> ofAll(byte[] array)
array
- a byte arraypublic static TreeSet<Character> ofAll(char[] array)
array
- a char arraypublic static TreeSet<Double> ofAll(double[] array)
array
- a double arraypublic static TreeSet<Float> ofAll(float[] array)
array
- a float arraypublic static TreeSet<Integer> ofAll(int[] array)
array
- an int arraypublic static TreeSet<Long> ofAll(long[] array)
array
- a long arraypublic static TreeSet<Short> ofAll(short[] array)
array
- a short arraypublic static TreeSet<Integer> range(int from, int toExclusive)
from
, extending to toExclusive - 1
.
Examples:
TreeSet.range(0, 0) // = TreeSet()
TreeSet.range(2, 0) // = TreeSet()
TreeSet.range(-2, 2) // = TreeSet(-2, -1, 0, 1)
from
- the first numbertoExclusive
- the last number + 1from >= toExclusive
public static TreeSet<Integer> rangeBy(int from, int toExclusive, int step)
from
, extending to toExclusive - 1
,
with step
.
Examples:
TreeSet.rangeBy(1, 3, 1) // = TreeSet(1, 2)
TreeSet.rangeBy(1, 4, 2) // = TreeSet(1, 3)
TreeSet.rangeBy(4, 1, -2) // = TreeSet(4, 2)
TreeSet.rangeBy(4, 1, 2) // = TreeSet()
from
- the first numbertoExclusive
- the last number + 1step
- the stepfrom >= toInclusive
and step > 0
orfrom <= toInclusive
and step < 0
IllegalArgumentException
- if step
is zeropublic static TreeSet<Long> range(long from, long toExclusive)
from
, extending to toExclusive - 1
.
Examples:
TreeSet.range(0L, 0L) // = TreeSet()
TreeSet.range(2L, 0L) // = TreeSet()
TreeSet.range(-2L, 2L) // = TreeSet(-2L, -1L, 0L, 1L)
from
- the first numbertoExclusive
- the last number + 1from >= toExclusive
public static TreeSet<Long> rangeBy(long from, long toExclusive, long step)
from
, extending to toExclusive - 1
,
with step
.
Examples:
TreeSet.rangeBy(1L, 3L, 1L) // = TreeSet(1L, 2L)
TreeSet.rangeBy(1L, 4L, 2L) // = TreeSet(1L, 3L)
TreeSet.rangeBy(4L, 1L, -2L) // = TreeSet(4L, 2L)
TreeSet.rangeBy(4L, 1L, 2L) // = TreeSet()
from
- the first numbertoExclusive
- the last number + 1step
- the stepfrom >= toInclusive
and step > 0
orfrom <= toInclusive
and step < 0
IllegalArgumentException
- if step
is zeropublic static TreeSet<Integer> rangeClosed(int from, int toInclusive)
from
, extending to toInclusive
.
Examples:
TreeSet.rangeClosed(0, 0) // = TreeSet(0)
TreeSet.rangeClosed(2, 0) // = TreeSet()
TreeSet.rangeClosed(-2, 2) // = TreeSet(-2, -1, 0, 1, 2)
from
- the first numbertoInclusive
- the last numberfrom > toInclusive
public static TreeSet<Integer> rangeClosedBy(int from, int toInclusive, int step)
from
, extending to toInclusive
,
with step
.
Examples:
TreeSet.rangeClosedBy(1, 3, 1) // = TreeSet(1, 2, 3)
TreeSet.rangeClosedBy(1, 4, 2) // = TreeSet(1, 3)
TreeSet.rangeClosedBy(4, 1, -2) // = TreeSet(4, 2)
TreeSet.rangeClosedBy(4, 1, 2) // = TreeSet()
from
- the first numbertoInclusive
- the last numberstep
- the stepfrom > toInclusive
and step > 0
orfrom < toInclusive
and step < 0
IllegalArgumentException
- if step
is zeropublic static TreeSet<Double> rangeClosedBy(double from, double toInclusive, double step)
public static TreeSet<Long> rangeClosed(long from, long toInclusive)
from
, extending to toInclusive
.
Examples:
TreeSet.rangeClosed(0L, 0L) // = TreeSet(0L)
TreeSet.rangeClosed(2L, 0L) // = TreeSet()
TreeSet.rangeClosed(-2L, 2L) // = TreeSet(-2L, -1L, 0L, 1L, 2L)
from
- the first numbertoInclusive
- the last numberfrom > toInclusive
public static TreeSet<Long> rangeClosedBy(long from, long toInclusive, long step)
from
, extending to toInclusive
,
with step
.
Examples:
TreeSet.rangeClosedBy(1L, 3L, 1L) // = TreeSet(1L, 2L, 3L)
TreeSet.rangeClosedBy(1L, 4L, 2L) // = TreeSet(1L, 3L)
TreeSet.rangeClosedBy(4L, 1L, -2L) // = TreeSet(4L, 2L)
TreeSet.rangeClosedBy(4L, 1L, 2L) // = TreeSet()
from
- the first numbertoInclusive
- the last numberstep
- the stepfrom > toInclusive
and step > 0
orfrom < toInclusive
and step < 0
IllegalArgumentException
- if step
is zeropublic TreeSet<T> add(T element)
Set
public TreeSet<T> addAll(Iterable<? extends T> elements)
Set
public Comparator<T> comparator()
SortedSet
comparator
in interface SortedSet<T>
public TreeSet<T> diff(Set<? extends T> elements)
Set
See also Set.removeAll(Iterable)
.
public boolean contains(T element)
Value
exists(e -> Objects.equals(e, element))
, tests if the given element
is contained.public TreeSet<T> distinct()
Traversable
equals
.public TreeSet<T> distinctBy(Comparator<? super T> comparator)
Traversable
comparator
.distinctBy
in interface Set<T>
distinctBy
in interface SortedSet<T>
distinctBy
in interface Traversable<T>
comparator
- A comparatorTraversable
containing this elements without duplicatespublic <U> TreeSet<T> distinctBy(Function<? super T,? extends U> keyExtractor)
Traversable
equals
.
The elements of the result are determined in the order of their occurrence - first match wins.
distinctBy
in interface Set<T>
distinctBy
in interface SortedSet<T>
distinctBy
in interface Traversable<T>
U
- key typekeyExtractor
- A key extractorTraversable
containing this elements without duplicatespublic TreeSet<T> drop(long n)
Traversable
drop
in interface Set<T>
drop
in interface SortedSet<T>
drop
in interface Traversable<T>
n
- The number of elements to drop.public TreeSet<T> dropRight(long n)
Traversable
dropRight
in interface Set<T>
dropRight
in interface SortedSet<T>
dropRight
in interface Traversable<T>
n
- The number of elements to drop.public TreeSet<T> dropUntil(Predicate<? super T> predicate)
Traversable
Note: This is essentially the same as dropWhile(predicate.negate())
. It is intended to be used with
method references, which cannot be negated directly.
dropUntil
in interface Set<T>
dropUntil
in interface SortedSet<T>
dropUntil
in interface Traversable<T>
predicate
- A condition tested subsequently for this elements.public TreeSet<T> dropWhile(Predicate<? super T> predicate)
Traversable
dropWhile
in interface Set<T>
dropWhile
in interface SortedSet<T>
dropWhile
in interface Traversable<T>
predicate
- A condition tested subsequently for this elements starting with the first.public TreeSet<T> filter(Predicate<? super T> predicate)
Traversable
public <U> TreeSet<U> flatMap(Comparator<? super U> comparator, Function<? super T,? extends Iterable<? extends U>> mapper)
SortedSet
SortedSet.flatMap(Function)
but using a specific comparator for values of the codomain of the given
mapper
.public <U> TreeSet<U> flatMap(Function<? super T,? extends Iterable<? extends U>> mapper)
Traversable
public <U> U foldRight(U zero, BiFunction<? super T,? super U,? extends U> f)
Traversable
f
from the right,
starting with a value zero
of type B.
Example: List.of("a", "b", "c").foldRight("", (x, xs) -> x + xs) = "abc"
public <C> Map<C,TreeSet<T>> groupBy(Function<? super T,? extends C> classifier)
Traversable
groupBy
in interface Set<T>
groupBy
in interface SortedSet<T>
groupBy
in interface Traversable<T>
C
- classified class typeclassifier
- A function which classifies elements into classespublic Iterator<TreeSet<T>> grouped(long size)
Traversable
Traversable
into fixed size blocks.
Let length be the length of this Iterable. Then grouped is defined as follows:
this.isEmpty()
, the resulting Iterator
is empty.size <= length
, the resulting Iterator
will contain length / size
blocks of size
size
and maybe a non-empty block of size length % size
, if there are remaining elements.size > length
, the resulting Iterator
will contain one block of size length
.
[].grouped(1) = []
[].grouped(0) throws
[].grouped(-1) throws
[1,2,3,4].grouped(2) = [[1,2],[3,4]]
[1,2,3,4,5].grouped(2) = [[1,2],[3,4],[5]]
[1,2,3,4].grouped(5) = [[1,2,3,4]]
Please note that grouped(int)
is a special case of Traversable.sliding(long, long), i.e.
grouped(size)
is the same as sliding(size, size)
.public boolean hasDefiniteSize()
Traversable
This method should be implemented by classes only, i.e. not by interfaces.
hasDefiniteSize
in interface Traversable<T>
public T head()
Traversable
head
in interface Traversable<T>
public Option<T> headOption()
Traversable
Option
.headOption
in interface Traversable<T>
Some(element)
or None
if this is empty.public TreeSet<T> init()
Traversable
public Option<TreeSet<T>> initOption()
Traversable
Option
.initOption
in interface Set<T>
initOption
in interface SortedSet<T>
initOption
in interface Traversable<T>
Some(traversable)
or None
if this is empty.public TreeSet<T> intersect(Set<? extends T> elements)
Set
See also Set.retainAll(Iterable)
.
public boolean isEmpty()
Traversable
public boolean isTraversableAgain()
Traversable
This method should be implemented by classes only, i.e. not by interfaces.
isTraversableAgain
in interface Traversable<T>
public Iterator<T> iterator()
Traversable
public int length()
Traversable
Same as Traversable.size()
.
public <U> TreeSet<U> map(Comparator<? super U> comparator, Function<? super T,? extends U> mapper)
SortedSet
SortedSet.map(Function)
but using a specific comparator for values of the codomain of the given
mapper
.public <U> TreeSet<U> map(Function<? super T,? extends U> mapper)
Traversable
Traversable
to elements of a new type preserving their order, if any.public Option<T> max()
Traversable
max
in interface Traversable<T>
Some(maximum)
of this elements or None
if this is empty or this elements are not comparablepublic Option<T> min()
Traversable
min
in interface Traversable<T>
Some(minimum)
of this elements or None
if this is empty or this elements are not comparablepublic Tuple2<TreeSet<T>,TreeSet<T>> partition(Predicate<? super T> predicate)
Traversable
Traversable
by splitting this elements in two in distinct tarversables
according to a predicate.partition
in interface Set<T>
partition
in interface SortedSet<T>
partition
in interface Traversable<T>
predicate
- A predicate which classifies an element if it is in the first or the second traversable.Traversable
contains all elements that satisfy the given predicate
, the second Traversable
contains all elements that don't. The original order of elements is preserved.public TreeSet<T> peek(Consumer<? super T> action)
Value
action
on the first element if this is an eager implementation.
Performs the given action
on all elements (the first immediately, successive deferred),
if this is a lazy implementation.public TreeSet<T> remove(T element)
Set
public TreeSet<T> removeAll(Iterable<? extends T> elements)
Set
public TreeSet<T> replace(T currentElement, T newElement)
Traversable
replace
in interface Set<T>
replace
in interface SortedSet<T>
replace
in interface Traversable<T>
currentElement
- An element to be substituted.newElement
- A replacement for currentElement.public TreeSet<T> replaceAll(T currentElement, T newElement)
Traversable
replaceAll
in interface Set<T>
replaceAll
in interface SortedSet<T>
replaceAll
in interface Traversable<T>
currentElement
- An element to be substituted.newElement
- A replacement for currentElement.public TreeSet<T> retainAll(Iterable<? extends T> elements)
Traversable
public TreeSet<T> scan(T zero, BiFunction<? super T,? super T,? extends T> operation)
Traversable
scan
in interface Set<T>
scan
in interface SortedSet<T>
scan
in interface Traversable<T>
zero
- neutral element for the operator opoperation
- the associative operator for the scanpublic <U> Set<U> scanLeft(U zero, BiFunction<? super U,? super T,? extends U> operation)
Traversable
scanLeft
in interface Set<T>
scanLeft
in interface SortedSet<T>
scanLeft
in interface Traversable<T>
U
- the type of the elements in the resulting collectionzero
- the initial valueoperation
- the binary operator applied to the intermediate result and the elementpublic <U> Set<U> scanRight(U zero, BiFunction<? super T,? super U,? extends U> operation)
Traversable
scanRight
in interface Set<T>
scanRight
in interface SortedSet<T>
scanRight
in interface Traversable<T>
U
- the type of the elements in the resulting collectionzero
- the initial valueoperation
- the binary operator applied to the intermediate result and the elementpublic Iterator<TreeSet<T>> sliding(long size)
Traversable
size
and step size 1 over this Traversable
by calling
Traversable.sliding(long, long)
.public Iterator<TreeSet<T>> sliding(long size, long step)
Traversable
size
and step
size over this Traversable
.
Examples:
[].sliding(1,1) = []
[1,2,3,4,5].sliding(2,3) = [[1,2],[4,5]]
[1,2,3,4,5].sliding(2,4) = [[1,2],[5]]
[1,2,3,4,5].sliding(2,5) = [[1,2]]
[1,2,3,4].sliding(5,3) = [[1,2,3,4],[4]]
public Tuple2<TreeSet<T>,TreeSet<T>> span(Predicate<? super T> predicate)
Traversable
predicate
and the second element is the remainder.public TreeSet<T> tail()
Traversable
public Option<TreeSet<T>> tailOption()
Traversable
Option
.tailOption
in interface Set<T>
tailOption
in interface SortedSet<T>
tailOption
in interface Traversable<T>
Some(traversable)
or None
if this is empty.public TreeSet<T> take(long n)
Traversable
The result is equivalent to sublist(0, max(0, min(length(), n)))
but does not throw if n < 0
or
n > length()
.
In the case of n < 0
the empty instance is returned, in the case of n > length()
this is returned.
public TreeSet<T> takeRight(long n)
Traversable
The result is equivalent to sublist(max(0, min(length(), length() - n)), n)
, i.e. takeRight will not
throw if n < 0
or n > length()
.
In the case of n < 0
the empty instance is returned, in the case of n > length()
this is returned.
takeRight
in interface Set<T>
takeRight
in interface SortedSet<T>
takeRight
in interface Traversable<T>
n
- The number of elements to take.public TreeSet<T> takeUntil(Predicate<? super T> predicate)
Traversable
Note: This is essentially the same as takeWhile(predicate.negate())
. It is intended to be used with
method references, which cannot be negated directly.
takeUntil
in interface Set<T>
takeUntil
in interface SortedSet<T>
takeUntil
in interface Traversable<T>
predicate
- A condition tested subsequently for this elements.public TreeSet<T> takeWhile(Predicate<? super T> predicate)
Traversable
takeWhile
in interface Set<T>
takeWhile
in interface SortedSet<T>
takeWhile
in interface Traversable<T>
predicate
- A condition tested subsequently for the contained elements.public <U> U transform(Function<? super TreeSet<T>,? extends U> f)
TreeSet
.U
- Type of transformation resultf
- A transformationU
NullPointerException
- if f
is nullpublic TreeSet<T> toJavaSet()
Set
Set
to a java.util.Set
while preserving characteristics
like insertion order (LinkedHashSet
) and sort order (SortedSet
).public TreeSet<T> union(Set<? extends T> elements)
Set
that
set to this set, if not already present.
See also Set.addAll(Iterable)
.
public <T1,T2> Tuple2<TreeSet<T1>,TreeSet<T2>> unzip(Function<? super T,Tuple2<? extends T1,? extends T2>> unzipper)
Traversable
unzip
in interface Set<T>
unzip
in interface SortedSet<T>
unzip
in interface Traversable<T>
T1
- 1st element type of a pair returned by unzipperT2
- 2nd element type of a pair returned by unzipperunzipper
- a function which converts elements of this to pairspublic <T1,T2,T3> Tuple3<TreeSet<T1>,TreeSet<T2>,TreeSet<T3>> unzip3(Function<? super T,Tuple3<? extends T1,? extends T2,? extends T3>> unzipper)
Traversable
unzip3
in interface Set<T>
unzip3
in interface Traversable<T>
T1
- 1st element type of a triplet returned by unzipperT2
- 2nd element type of a triplet returned by unzipperT3
- 3rd element type of a triplet returned by unzipperunzipper
- a function which converts elements of this to pairspublic <U> TreeSet<Tuple2<T,U>> zip(Iterable<? extends U> that)
Traversable
The length of the returned traversable is the minimum of the lengths of this traversable and that
iterable.
zip
in interface Set<T>
zip
in interface SortedSet<T>
zip
in interface Traversable<T>
U
- The type of the second half of the returned pairs.that
- The Iterable providing the second half of each result pair.that
iterable.public <U> TreeSet<Tuple2<T,U>> zipAll(Iterable<? extends U> that, T thisElem, U thatElem)
Traversable
The length of the returned traversable is the maximum of the lengths of this traversable and that
iterable.
Special case: if this traversable is shorter than that elements, and that elements contains duplicates, the resulting traversable may be shorter than the maximum of the lengths of this and that because a traversable contains an element at most once.
If this Traversable is shorter than that, thisElem values are used to fill the result. If that is shorter than this Traversable, thatElem values are used to fill the result.
zipAll
in interface Set<T>
zipAll
in interface SortedSet<T>
zipAll
in interface Traversable<T>
U
- The type of the second half of the returned pairs.that
- The Iterable providing the second half of each result pair.thisElem
- The element to be used to fill up the result if this traversable is shorter than that.thatElem
- The element to be used to fill up the result if that is shorter than this traversable.public TreeSet<Tuple2<T,Long>> zipWithIndex()
Traversable
zipWithIndex
in interface Set<T>
zipWithIndex
in interface SortedSet<T>
zipWithIndex
in interface Traversable<T>
public boolean equals(Object o)
Value
public int hashCode()
Value
See Object.hashCode().
public String stringPrefix()
Value
stringPrefix
in interface Value<T>
Copyright © 2016. All Rights Reserved.