Modifier and Type | Interface and Description |
---|---|
static class |
BitSet.Builder<T> |
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Modifier and Type | Method and Description |
---|---|
BitSet<T> |
add(T element)
Add the given element to this set, if it is not already contained.
|
BitSet<T> |
addAll(Iterable<? extends T> elements)
Adds all of the given elements to this set, if not already contained.
|
default <R> SortedSet<R> |
collect(PartialFunction<? super T,? extends R> partialFunction)
Collects all elements that are in the domain of the given
partialFunction by mapping the elements to type R . |
static Collector<Integer,ArrayList<Integer>,BitSet<Integer>> |
collector()
Returns a
Collector which may be used in conjunction with
Stream.collect(java.util.stream.Collector) to obtain a BitSet . |
default BitSet<T> |
diff(Set<? extends T> elements)
Calculates the difference between this set and another set.
|
default BitSet<T> |
distinct()
Returns a new version of this which contains no duplicates.
|
BitSet<T> |
distinctBy(Comparator<? super T> comparator)
Returns a new version of this which contains no duplicates.
|
<U> BitSet<T> |
distinctBy(Function<? super T,? extends U> keyExtractor)
Returns a new version of this which contains no duplicates.
|
BitSet<T> |
drop(int n)
Drops the first n elements of this or all elements, if this length < n.
|
BitSet<T> |
dropRight(int n)
Drops the last n elements of this or all elements, if this length < n.
|
default BitSet<T> |
dropUntil(Predicate<? super T> predicate)
Drops elements until the predicate holds for the current element.
|
BitSet<T> |
dropWhile(Predicate<? super T> predicate)
Drops elements while the predicate holds for the current element.
|
static BitSet<Integer> |
empty() |
static BitSet<Integer> |
fill(int n,
Supplier<Integer> s)
Returns a BitSet containing
n values supplied by a given Supplier s . |
BitSet<T> |
filter(Predicate<? super T> predicate)
Returns a new traversable consisting of all elements which satisfy the given predicate.
|
default <U> SortedSet<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 . |
default <U> SortedSet<U> |
flatMap(Function<? super T,? extends Iterable<? extends U>> mapper)
FlatMaps this Traversable.
|
default <U> U |
foldRight(U zero,
BiFunction<? super T,? super U,? extends U> f)
Folds this elements from the right, starting with
zero and successively calling combine . |
<C> Map<C,BitSet<T>> |
groupBy(Function<? super T,? extends C> classifier)
Groups this elements by classifying the elements.
|
default Iterator<BitSet<T>> |
grouped(int size)
Groups this
Traversable into fixed size blocks. |
default boolean |
hasDefiniteSize()
Checks if this Traversable is known to have a finite size.
|
BitSet<T> |
init()
Dual of Traversable.tail(), returning all elements except the last.
|
default Option<BitSet<T>> |
initOption()
Dual of Traversable.tailOption(), returning all elements except the last as
Option . |
BitSet<T> |
intersect(Set<? extends T> elements)
Computes the intersection between this set and another set.
|
default boolean |
isAsync()
An
BitSet 's value is computed synchronously. |
default boolean |
isLazy()
An
BitSet 's value is computed eagerly. |
default boolean |
isTraversableAgain()
Checks if this Traversable can be repeatedly traversed.
|
default T |
last()
Dual of Traversable.head(), returning the last element.
|
default <U> SortedSet<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 . |
default <U> SortedSet<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. |
static BitSet<Integer> |
of(Integer... values) |
static BitSet<Integer> |
of(Integer value) |
static BitSet<Boolean> |
ofAll(boolean... elements)
Creates a BitSet from boolean values.
|
static BitSet<Byte> |
ofAll(byte... elements)
Creates a BitSet from byte values.
|
static BitSet<Character> |
ofAll(char... elements)
Creates a BitSet from char values.
|
static BitSet<Integer> |
ofAll(int... elements)
Creates a BitSet from int values.
|
static BitSet<Integer> |
ofAll(Iterable<Integer> values) |
static BitSet<Long> |
ofAll(long... elements)
Creates a BitSet from long values.
|
static BitSet<Short> |
ofAll(short... elements)
Creates a BitSet from short values.
|
static BitSet<Integer> |
ofAll(Stream<Integer> javaStream) |
Tuple2<BitSet<T>,BitSet<T>> |
partition(Predicate<? super T> predicate)
Creates a partition of this
Traversable by splitting this elements in two in distinct traversables
according to a predicate. |
default BitSet<T> |
peek(Consumer<? super T> action)
Performs the given
action on the first element if this is an eager implementation. |
static BitSet<Character> |
range(char from,
char toExclusive) |
static BitSet<Integer> |
range(int from,
int toExclusive)
Creates a BitSet of int numbers starting from
from , extending to toExclusive - 1 . |
static BitSet<Long> |
range(long from,
long toExclusive) |
static BitSet<Character> |
rangeBy(char from,
char toExclusive,
int step) |
static BitSet<Integer> |
rangeBy(int from,
int toExclusive,
int step)
Creates a BitSet of int numbers starting from
from , extending to toExclusive - 1 ,
with step . |
static BitSet<Long> |
rangeBy(long from,
long toExclusive,
long step) |
static BitSet<Character> |
rangeClosed(char from,
char toInclusive) |
static BitSet<Integer> |
rangeClosed(int from,
int toInclusive)
Creates a BitSet of int numbers starting from
from , extending to toInclusive . |
static BitSet<Long> |
rangeClosed(long from,
long toInclusive) |
static BitSet<Character> |
rangeClosedBy(char from,
char toInclusive,
int step) |
static BitSet<Integer> |
rangeClosedBy(int from,
int toInclusive,
int step)
Creates a BitSet of int numbers starting from
from , extending to toInclusive ,
with step . |
static BitSet<Long> |
rangeClosedBy(long from,
long toInclusive,
long step) |
BitSet<T> |
reject(Predicate<? super T> predicate)
Returns a new traversable consisting of all elements which do not satisfy the given predicate.
|
BitSet<T> |
remove(T element)
Removes a specific element from this set, if present.
|
BitSet<T> |
removeAll(Iterable<? extends T> elements)
Removes all of the given elements from this set, if present.
|
default BitSet<T> |
replace(T currentElement,
T newElement)
Replaces the first occurrence (if exists) of the given currentElement with newElement.
|
default BitSet<T> |
replaceAll(T currentElement,
T newElement)
Replaces all occurrences of the given currentElement with newElement.
|
default BitSet<T> |
retainAll(Iterable<? extends T> elements)
Keeps all occurrences of the given elements from this.
|
BitSet<T> |
scan(T zero,
BiFunction<? super T,? super T,? extends T> operation)
Computes a prefix scan of the elements of the collection.
|
default <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.
|
default <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<BitSet<T>> |
slideBy(Function<? super T,?> classifier)
Slides a non-overlapping window of a variable size over this
Traversable . |
default Iterator<BitSet<T>> |
sliding(int size)
Slides a window of a specific
size and step size 1 over this Traversable by calling
Traversable.sliding(int, int) . |
Iterator<BitSet<T>> |
sliding(int size,
int step)
Slides a window of a specific
size and step size over this Traversable . |
Tuple2<BitSet<T>,BitSet<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. |
default String |
stringPrefix()
Returns the name of this Value type, which is used by toString().
|
static BitSet<Integer> |
tabulate(int n,
Function<Integer,Integer> f)
Returns a BitSet containing
n values of a given Function f
over a range of integer values from 0 to n - 1 . |
default BitSet<T> |
tail()
Drops the first element of a non-empty Traversable.
|
default Option<BitSet<T>> |
tailOption()
Drops the first element of a non-empty Traversable and returns an
Option . |
BitSet<T> |
take(int n)
Takes the first n elements of this or all elements, if this length < n.
|
BitSet<T> |
takeRight(int n)
Takes the last n elements of this or all elements, if this length < n.
|
default BitSet<T> |
takeUntil(Predicate<? super T> predicate)
Takes elements until the predicate holds for the current element.
|
BitSet<T> |
takeWhile(Predicate<? super T> predicate)
Takes elements while the predicate holds for the current element.
|
default SortedSet<T> |
toJavaSet()
Converts this Vavr
Set to a java.util.Set while preserving characteristics
like insertion order (LinkedHashSet ) and sort order (SortedSet ). |
default BitSet<T> |
union(Set<? extends T> elements)
Adds all of the elements of
that set to this set, if not already present. |
default <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.
|
default <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.
|
static BitSet.Builder<Byte> |
withBytes() |
static BitSet.Builder<Character> |
withCharacters() |
static <T extends Enum<T>> |
withEnum(Class<T> enumClass) |
static BitSet.Builder<Long> |
withLongs() |
static <T> BitSet.Builder<T> |
withRelations(Function1<Integer,T> fromInt,
Function1<T,Integer> toInt) |
static BitSet.Builder<Short> |
withShorts() |
default <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.
|
default <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.
|
default <U,R> TreeSet<R> |
zipWith(Iterable<? extends U> that,
BiFunction<? super T,? super U,? extends R> mapper)
Returns a traversable formed from this traversable and another Iterable collection by mapping elements.
|
default TreeSet<Tuple2<T,Integer>> |
zipWithIndex()
Zips this traversable with its indices.
|
default <U> TreeSet<U> |
zipWithIndex(BiFunction<? super T,? super Integer,? extends U> mapper)
Returns a traversable formed from this traversable and another Iterable collection by mapping elements.
|
apply, contains, isDistinct, iterator, length, narrow
arrangeBy, average, containsAll, count, equals, existsUnique, find, findLast, foldLeft, forEachWithIndex, get, hashCode, head, headOption, isEmpty, isSequential, isSingleValued, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, narrow, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, single, singleOption, size, spliterator, sum
fold, reduce, reduceOption
collect, collect, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, narrow, out, out, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toString, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
andThen, arity, compose, constant, curried, identity, isMemoized, lift, liftTry, memoized, narrow, of, partial, reversed, tupled
comparator
static final long serialVersionUID
static <T> BitSet.Builder<T> withRelations(Function1<Integer,T> fromInt, Function1<T,Integer> toInt)
static <T extends Enum<T>> BitSet.Builder<T> withEnum(Class<T> enumClass)
static BitSet.Builder<Character> withCharacters()
static BitSet.Builder<Byte> withBytes()
static BitSet.Builder<Long> withLongs()
static BitSet.Builder<Short> withShorts()
static Collector<Integer,ArrayList<Integer>,BitSet<Integer>> collector()
Collector
which may be used in conjunction with
Stream.collect(java.util.stream.Collector)
to obtain a BitSet
.BitSet
Collector.static BitSet<Integer> tabulate(int n, Function<Integer,Integer> f)
n
values of a given Function f
over a range of integer values from 0 to n - 1
.n
- The number of elements in the BitSetf
- The Function computing element valuesf(0),f(1), ..., f(n - 1)
NullPointerException
- if f
is nullstatic BitSet<Integer> fill(int n, Supplier<Integer> s)
n
values supplied by a given Supplier s
.n
- The number of elements in the BitSets
- The Supplier computing element valuesn
, where each element contains the result supplied by s
.NullPointerException
- if s
is nullstatic BitSet<Boolean> ofAll(boolean... elements)
elements
- boolean valuesNullPointerException
- if elements is nullstatic BitSet<Byte> ofAll(byte... elements)
elements
- byte valuesNullPointerException
- if elements is nullstatic BitSet<Character> ofAll(char... elements)
elements
- char valuesNullPointerException
- if elements is nullstatic BitSet<Integer> ofAll(int... elements)
elements
- int valuesNullPointerException
- if elements is nullstatic BitSet<Long> ofAll(long... elements)
elements
- long valuesNullPointerException
- if elements is nullstatic BitSet<Short> ofAll(short... elements)
elements
- short valuesNullPointerException
- if elements is nullstatic BitSet<Integer> range(int from, int toExclusive)
from
, extending to toExclusive - 1
.from
- the first numbertoExclusive
- the last number + 1from >= toExclusive
static BitSet<Integer> rangeBy(int from, int toExclusive, int step)
from
, extending to toExclusive - 1
,
with step
.from
- the first numbertoExclusive
- the last number + 1step
- the stepfrom >= toInclusive
and step > 0
orfrom <= toInclusive
and step < 0
IllegalArgumentException
- if step
is zerostatic BitSet<Integer> rangeClosed(int from, int toInclusive)
from
, extending to toInclusive
.from
- the first numbertoInclusive
- the last numberfrom > toInclusive
static BitSet<Integer> rangeClosedBy(int from, int toInclusive, int step)
from
, extending to toInclusive
,
with step
.from
- the first numbertoInclusive
- the last numberstep
- the stepfrom > toInclusive
and step > 0
orfrom < toInclusive
and step < 0
IllegalArgumentException
- if step
is zeroBitSet<T> add(T element)
Set
BitSet<T> addAll(Iterable<? extends T> elements)
Set
default <R> SortedSet<R> collect(PartialFunction<? super T,? extends R> partialFunction)
Traversable
partialFunction
by mapping the elements to type R
.
More specifically, for each of this elements in iteration order first it is checked
partialFunction.isDefinedAt(element)
If the elements makes it through that filter, the mapped instance is added to the result collection
R newElement = partialFunction.apply(element)
Note:If this Traversable
is ordered (i.e. extends Ordered
,
the caller of collect
has to ensure that the elements are comparable (i.e. extend Comparable
).collect
in interface Set<T>
collect
in interface SortedSet<T>
collect
in interface Traversable<T>
R
- The new element typepartialFunction
- A function that is not necessarily defined of all elements of this traversable.Traversable
instance containing elements of type R
default BitSet<T> diff(Set<? extends T> elements)
Set
See also Set.removeAll(Iterable)
.
default BitSet<T> distinct()
Traversable
equals
.BitSet<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 duplicates<U> BitSet<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 duplicatesBitSet<T> drop(int n)
Traversable
drop
in interface Set<T>
drop
in interface SortedSet<T>
drop
in interface Traversable<T>
n
- The number of elements to drop.BitSet<T> dropRight(int n)
Traversable
dropRight
in interface Set<T>
dropRight
in interface SortedSet<T>
dropRight
in interface Traversable<T>
n
- The number of elements to drop.default BitSet<T> dropUntil(Predicate<? super T> predicate)
Traversable
dropUntil
in interface Set<T>
dropUntil
in interface SortedSet<T>
dropUntil
in interface Traversable<T>
predicate
- A condition tested subsequently for this elements.BitSet<T> dropWhile(Predicate<? super T> predicate)
Traversable
Note: This is essentially the same as dropUntil(predicate.negate())
.
It is intended to be used with method references, which cannot be negated directly.
dropWhile
in interface Set<T>
dropWhile
in interface SortedSet<T>
dropWhile
in interface Traversable<T>
predicate
- A condition tested subsequently for this elements.BitSet<T> filter(Predicate<? super T> predicate)
Traversable
BitSet<T> reject(Predicate<? super T> predicate)
Traversable
The default implementation is equivalent to
filter(predicate.negate()
default <U> SortedSet<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
.default <U> SortedSet<U> flatMap(Function<? super T,? extends Iterable<? extends U>> mapper)
Traversable
default <U> U foldRight(U zero, BiFunction<? super T,? super U,? extends U> f)
Foldable
zero
and successively calling combine
.
Example:
// = "!cba"
List("a", "b", "c").foldRight("!", (x, xs) -> xs + x)
<C> Map<C,BitSet<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 classesTraversable.arrangeBy(Function)
default Iterator<BitSet<T>> grouped(int 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(int, int), i.e.
grouped(size)
is the same as sliding(size, size)
.default boolean hasDefiniteSize()
Traversable
This method should be implemented by classes only, i.e. not by interfaces.
hasDefiniteSize
in interface Traversable<T>
BitSet<T> init()
Traversable
default Option<BitSet<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.default boolean isAsync()
BitSet
's value is computed synchronously.default boolean isTraversableAgain()
Traversable
This method should be implemented by classes only, i.e. not by interfaces.
isTraversableAgain
in interface Traversable<T>
default boolean isLazy()
BitSet
's value is computed eagerly.BitSet<T> intersect(Set<? extends T> elements)
Set
See also Set.retainAll(Iterable)
.
default T last()
Traversable
last
in interface Traversable<T>
Tuple2<BitSet<T>,BitSet<T>> partition(Predicate<? super T> predicate)
Traversable
Traversable
by splitting this elements in two in distinct traversables
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.default BitSet<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.default String stringPrefix()
Value
stringPrefix
in interface Value<T>
default <U> SortedSet<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
.default <U> SortedSet<U> map(Function<? super T,? extends U> mapper)
Traversable
Traversable
to elements of a new type preserving their order, if any.BitSet<T> remove(T element)
Set
BitSet<T> removeAll(Iterable<? extends T> elements)
Set
default BitSet<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.default BitSet<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.default BitSet<T> retainAll(Iterable<? extends T> elements)
Traversable
BitSet<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 scandefault <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 elementdefault <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 elementIterator<BitSet<T>> slideBy(Function<? super T,?> classifier)
Traversable
Traversable
.
Each window contains elements with the same class, as determined by classifier
. Two consecutive
values in this Traversable
will be in the same window only if classifier
returns equal
values for them. Otherwise, the values will constitute the last element of the previous window and the
first element of the next window.
Examples:
[].slideBy(Function.identity()) = []
[1,2,3,4,4,5].slideBy(Function.identity()) = [[1],[2],[3],[4,4],[5]]
[1,2,3,10,12,5,7,20,29].slideBy(x -> x/10) = [[1,2,3],[10,12],[5,7],[20,29]]
default Iterator<BitSet<T>> sliding(int size)
Traversable
size
and step size 1 over this Traversable
by calling
Traversable.sliding(int, int)
.Iterator<BitSet<T>> sliding(int size, int 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]]
Tuple2<BitSet<T>,BitSet<T>> span(Predicate<? super T> predicate)
Traversable
predicate
and the second element is the remainder.default BitSet<T> tail()
Traversable
default Option<BitSet<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.BitSet<T> take(int 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.
BitSet<T> takeRight(int 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.default BitSet<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.BitSet<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.default SortedSet<T> toJavaSet()
Set
Set
to a java.util.Set
while preserving characteristics
like insertion order (LinkedHashSet
) and sort order (SortedSet
).default BitSet<T> union(Set<? extends T> elements)
Set
that
set to this set, if not already present.
See also Set.addAll(Iterable)
.
default <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 pairsdefault <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 SortedSet<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 pairsdefault <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.default <U,R> TreeSet<R> zipWith(Iterable<? extends U> that, BiFunction<? super T,? super U,? extends R> mapper)
Traversable
The length of the returned traversable is the minimum of the lengths of this traversable and that
iterable.
zipWith
in interface Set<T>
zipWith
in interface SortedSet<T>
zipWith
in interface Traversable<T>
U
- The type of the second parameter of the mapper.R
- The type of the mapped elements.that
- The Iterable providing the second parameter of the mapper.mapper
- a mapper.that
iterable.default <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.default TreeSet<Tuple2<T,Integer>> zipWithIndex()
Traversable
zipWithIndex
in interface Set<T>
zipWithIndex
in interface SortedSet<T>
zipWithIndex
in interface Traversable<T>
default <U> TreeSet<U> zipWithIndex(BiFunction<? super T,? super Integer,? extends U> mapper)
Traversable
The length of the returned traversable is the minimum of the lengths of this traversable and that
iterable.
zipWithIndex
in interface Set<T>
zipWithIndex
in interface SortedSet<T>
zipWithIndex
in interface Traversable<T>
U
- The type of the mapped elements.mapper
- a mapper.that
iterable.Copyright © 2020. All Rights Reserved.