Interface BitSet<T>
- Type Parameters:
T- Component type
- All Superinterfaces:
Foldable<T>, Function<T,Boolean>, Function1<T, Boolean>, Iterable<T>, Ordered<T>, Serializable, Set<T>, SortedSet<T>, Traversable<T>, Value<T>
- All Known Implementing Classes:
BitSetModule.AbstractBitSet, BitSetModule.BitSet1, BitSetModule.BitSet2, BitSetModule.BitSetN
BitSet implementation.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe serial version UID for serialization. -
Method Summary
Modifier and TypeMethodDescriptionReturns a new set containing all elements of this set plus the given element, if it was not already present.Returns a new set containing all elements of this set plus the given elements, excluding duplicates.default <R> SortedSet<R> collect(@NonNull PartialFunction<? super T, ? extends R> partialFunction) Applies aPartialFunctionto all elements that are defined for it and collects the results.Returns aCollectorwhich may be used in conjunction withStream.collect(java.util.stream.Collector)to obtain aBitSet.Returns a new set containing all elements of this set except those in the given set.distinct()Returns a newTraversablecontaining the elements of this instance with all duplicates removed.distinctBy(@NonNull Comparator<? super T> comparator) Returns a newTraversablecontaining the elements of this instance without duplicates, as determined by the givencomparator.distinctBy(@NonNull Function<? super T, ? extends U> keyExtractor) Returns a newTraversablecontaining the elements of this instance without duplicates, based on keys extracted from elements usingkeyExtractor.drop(int n) Returns a newTraversablewithout the firstnelements, or an empty instance if this contains fewer thannelements.dropRight(int n) Returns a newTraversablewithout the lastnelements, or an empty instance if this contains fewer thannelements.Returns a newTraversablestarting from the first element that satisfies the givenpredicate, dropping all preceding elements.Returns a newTraversablestarting from the first element that does not satisfy the givenpredicate, dropping all preceding elements.empty()Returns a BitSet containing no elements.Returns a BitSet containingnvalues supplied by a given Suppliers.Returns a new traversable containing only the elements that satisfy the given predicate.default <U> SortedSet<U> flatMap(@NonNull Comparator<? super U> comparator, Function<? super T, ? extends Iterable<? extends U>> mapper) Same asSortedSet.flatMap(Function)but using a specific comparator for values of the codomain of the givenmapper.default <U> SortedSet<U> Transforms each element of this Traversable into anIterableof elements and flattens the resulting iterables into a single Traversable.default <U> UfoldRight(U zero, @NonNull BiFunction<? super T, ? super U, ? extends U> f) Folds the elements of this structure from the right, starting with the givenzerovalue and successively applying thecombinefunction to each element.Groups elements of thisTraversablebased on a classifier function.grouped(int size) Splits thisTraversableinto consecutive blocks of the given size.default booleanIndicates whether thisTraversablehas a known finite size.init()Returns all elements of this Traversable except the last one.Returns all elements of this Traversable except the last one, wrapped in anOption.Returns a new set containing only the elements present in both this set and the given set.default booleanisAsync()AnBitSet's value is computed synchronously.default booleanisLazy()AnBitSet's value is computed eagerly.default booleanChecks if this Traversable can be traversed multiple times without side effects.default Tlast()Returns the last element of this Traversable.default <U> SortedSet<U> map(@NonNull Comparator<? super U> comparator, Function<? super T, ? extends U> mapper) Same asSortedSet.map(Function)but using a specific comparator for values of the codomain of the givenmapper.default <U> SortedSet<U> Transforms the elements of this Traversable to a new type, preserving order if defined.default <U> SortedSet<U> mapTo(U value) Maps the underlying value to another fixed value.Maps the underlying value to VoidReturns a BitSet containing a single value.Creates a BitSet of int numbers starting fromfrom, extending totoExclusive - 1.ofAll(boolean... elements) Creates a BitSet from boolean values.ofAll(byte... elements) Creates a BitSet from byte values.ofAll(char... elements) Creates a BitSet from char values.ofAll(int... elements) Creates a BitSet from int values.ofAll(long... elements) Creates a BitSet from long values.ofAll(short... elements) Creates a BitSet from short values.Creates a BitSet of int numbers starting fromfrom, extending totoExclusive - 1.Creates a BitSet of int numbers starting fromfrom, extending totoExclusive - 1.Splits thisTraversableinto two partitions according to a predicate.Performs the givenactionon the first element if this is an eager implementation.range(char from, char toExclusive) Creates a BitSet of char numbers starting fromfrom, extending totoExclusive - 1.range(int from, int toExclusive) Creates a BitSet of int numbers starting fromfrom, extending totoExclusive - 1.range(long from, long toExclusive) Creates a BitSet of long numbers starting fromfrom, extending totoExclusive - 1.rangeBy(char from, char toExclusive, int step) Creates a BitSet of char numbers starting fromfrom, extending totoExclusive - 1, withstep.rangeBy(int from, int toExclusive, int step) Creates a BitSet of int numbers starting fromfrom, extending totoExclusive - 1, withstep.rangeBy(long from, long toExclusive, long step) Creates a BitSet of long numbers starting fromfrom, extending totoExclusive - 1, withstep.rangeClosed(char from, char toInclusive) Creates a BitSet of char numbers starting fromfrom, extending totoInclusive.rangeClosed(int from, int toInclusive) Creates a BitSet of int numbers starting fromfrom, extending totoInclusive.rangeClosed(long from, long toInclusive) Creates a BitSet of long numbers starting fromfrom, extending totoInclusive.rangeClosedBy(char from, char toInclusive, int step) Creates a BitSet of char numbers starting fromfrom, extending totoInclusive, withstep.rangeClosedBy(int from, int toInclusive, int step) Creates a BitSet of int numbers starting fromfrom, extending totoInclusive, withstep.rangeClosedBy(long from, long toInclusive, long step) Creates a BitSet of long numbers starting fromfrom, extending totoInclusive, withstep.Returns a new traversable containing only the elements that do not satisfy the given predicate.Returns a new set with the given element removed, if it was present.Returns a new set with all given elements removed, if present.Replaces the first occurrence ofcurrentElementwithnewElement, if it exists.replaceAll(T currentElement, T newElement) Replaces all occurrences ofcurrentElementwithnewElement.Retains only the elements from this Traversable that are contained in the givenelements.Computes a prefix scan of the elements of this Traversable.default <U> Set<U> scanLeft(U zero, @NonNull BiFunction<? super U, ? super T, ? extends U> operation) Produces a collection containing cumulative results of applying the operator from left to right.default <U> Set<U> scanRight(U zero, @NonNull BiFunction<? super T, ? super U, ? extends U> operation) Produces a collection containing cumulative results of applying the operator from right to left.Partitions thisTraversableinto consecutive non-overlapping windows according to a classification function.sliding(int size) Slides a window of a givensizeover thisTraversablewith a step size of 1.sliding(int size, int step) Slides a window of a specificsizewith a givenstepover thisTraversable.Splits thisTraversableinto a prefix and remainder according to the givenpredicate.default StringReturns the name of this Value type, which is used by toString().Returns a BitSet containingnvalues of a given Functionfover a range of integer values from 0 ton - 1.tail()Returns a newTraversablewithout its first element.Returns a newTraversablewithout its first element as anOption.take(int n) Returns the firstnelements of thisTraversable, or all elements ifnexceeds the length.takeRight(int n) Returns the lastnelements of thisTraversable, or all elements ifnexceeds the length.Takes elements from thisTraversableuntil the given predicate holds for an element.Takes elements from thisTraversablewhile the given predicate holds.Converts this Vavr set to ajava.util.Set, preserving insertion or sort order.Returns a new set containing all distinct elements from this set and the given set.Unzips the elements of thisTraversableby mapping each element to a pair and splitting them into two separateTraversablecollections.Unzips the elements of thisTraversableby mapping each element to a triple and splitting them into three separateTraversablecollections.static BitSet.Builder<Byte> static BitSet.Builder<Character> static <T extends Enum<T>>
BitSet.Builder<T> Returns newBitSetBuilder for an enum typestatic BitSet.Builder<Long> static <T> BitSet.Builder<T> withRelations(Function1<Integer, T> fromInt, Function1<T, Integer> toInt) Returns newBitSetBuilder with custom conversion functions between Integer and type Tstatic BitSet.Builder<Short> Returns aTraversableformed by pairing elements of thisTraversablewith elements of anotherIterable.Returns aTraversableformed by pairing elements of thisTraversablewith elements of anotherIterable, filling in placeholder elements when one collection is shorter than the other.default <U,R> TreeSet <R> zipWith(@NonNull Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) Returns aTraversableby combining elements of thisTraversablewith elements of anotherIterableusing a mapping function.Zips thisTraversablewith its indices, starting at 0.default <U> TreeSet<U> zipWithIndex(@NonNull BiFunction<? super T, ? super Integer, ? extends U> mapper) Zips thisTraversablewith its indices and maps the resulting pairs using the provided mapper.Methods inherited from interface Foldable
fold, reduce, reduceOptionMethods inherited from interface Function1
andThen, arity, compose, compose1, curried, isMemoized, memoized, partial, reversed, tupledMethods inherited from interface Ordered
comparatorMethods inherited from interface Traversable
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, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, single, singleOption, size, spliterator, sumMethods inherited from interface Value
collect, collect, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, 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
-
Field Details
-
serialVersionUID
static final long serialVersionUIDThe serial version UID for serialization.- See Also:
-
-
Method Details
-
withRelations
static <T> BitSet.Builder<T> withRelations(Function1<Integer, T> fromInt, Function1<T, Integer> toInt) Returns newBitSetBuilder with custom conversion functions between Integer and type T- Type Parameters:
T- Component type- Parameters:
fromInt- function to convert from Integer to TtoInt- function to convert from T to Integer- Returns:
- new Builder
-
withEnum
Returns newBitSetBuilder for an enum type- Type Parameters:
T- Enum type- Parameters:
enumClass- the enum class- Returns:
- new Builder
-
withCharacters
- Returns:
- new Builder
-
withBytes
- Returns:
- new Builder
-
withLongs
- Returns:
- new Builder
-
withShorts
- Returns:
- new Builder
-
collector
-
empty
-
of
-
of
-
tabulate
Returns a BitSet containingnvalues of a given Functionfover a range of integer values from 0 ton - 1.- Parameters:
n- The number of elements in the BitSetf- The Function computing element values- Returns:
- A BitSet consisting of elements
f(0),f(1), ..., f(n - 1) - Throws:
NullPointerException- iffis null
-
fill
Returns a BitSet containingnvalues supplied by a given Suppliers.- Parameters:
n- The number of elements in the BitSets- The Supplier computing element values- Returns:
- A BitSet of size
n, where each element contains the result supplied bys. - Throws:
NullPointerException- ifsis null
-
ofAll
-
ofAll
-
ofAll
Creates a BitSet from boolean values.- Parameters:
elements- boolean values- Returns:
- A new BitSet of boolean values
- Throws:
NullPointerException- if elements is null
-
ofAll
Creates a BitSet from byte values.- Parameters:
elements- byte values- Returns:
- A new BitSet of byte values
- Throws:
NullPointerException- if elements is null
-
ofAll
Creates a BitSet from char values.- Parameters:
elements- char values- Returns:
- A new BitSet of char values
- Throws:
NullPointerException- if elements is null
-
ofAll
Creates a BitSet from int values.- Parameters:
elements- int values- Returns:
- A new BitSet of int values
- Throws:
NullPointerException- if elements is null
-
ofAll
Creates a BitSet from long values.- Parameters:
elements- long values- Returns:
- A new BitSet of long values
- Throws:
NullPointerException- if elements is null
-
ofAll
Creates a BitSet from short values.- Parameters:
elements- short values- Returns:
- A new BitSet of short values
- Throws:
NullPointerException- if elements is null
-
range
-
range
-
range
-
rangeBy
Creates a BitSet of int numbers starting fromfrom, extending totoExclusive - 1, withstep.- Parameters:
from- the first numbertoExclusive- the last number + 1step- the step- Returns:
- a range of long values as specified or the empty range if
from >= toInclusiveandstep > 0or
from <= toInclusiveandstep < 0 - Throws:
IllegalArgumentException- ifstepis zero
-
rangeBy
Creates a BitSet of char numbers starting fromfrom, extending totoExclusive - 1, withstep.- Parameters:
from- the first numbertoExclusive- the last number + 1step- the step- Returns:
- a range of char values as specified or the empty range if
from >= toInclusiveandstep > 0or
from <= toInclusiveandstep < 0 - Throws:
IllegalArgumentException- ifstepis zero
-
rangeBy
Creates a BitSet of long numbers starting fromfrom, extending totoExclusive - 1, withstep.- Parameters:
from- the first numbertoExclusive- the last number + 1step- the step- Returns:
- a range of long values as specified or the empty range if
from >= toInclusiveandstep > 0or
from <= toInclusiveandstep < 0 - Throws:
IllegalArgumentException- ifstepis zero
-
rangeClosed
-
rangeClosed
-
rangeClosed
-
rangeClosedBy
Creates a BitSet of int numbers starting fromfrom, extending totoInclusive, withstep.- Parameters:
from- the first numbertoInclusive- the last numberstep- the step- Returns:
- a range of int values as specified or the empty range if
from > toInclusiveandstep > 0or
from < toInclusiveandstep < 0 - Throws:
IllegalArgumentException- ifstepis zero
-
rangeClosedBy
Creates a BitSet of char numbers starting fromfrom, extending totoInclusive, withstep.- Parameters:
from- the first numbertoInclusive- the last numberstep- the step- Returns:
- a range of char values as specified or the empty range if
from > toInclusiveandstep > 0or
from < toInclusiveandstep < 0 - Throws:
IllegalArgumentException- ifstepis zero
-
rangeClosedBy
Creates a BitSet of long numbers starting fromfrom, extending totoInclusive, withstep.- Parameters:
from- the first numbertoInclusive- the last numberstep- the step- Returns:
- a range of long values as specified or the empty range if
from > toInclusiveandstep > 0or
from < toInclusiveandstep < 0 - Throws:
IllegalArgumentException- ifstepis zero
-
add
Description copied from interface:SetReturns a new set containing all elements of this set plus the given element, if it was not already present. -
addAll
Description copied from interface:SetReturns a new set containing all elements of this set plus the given elements, excluding duplicates. -
collect
Description copied from interface:TraversableApplies aPartialFunctionto all elements that are defined for it and collects the results.For each element in iteration order, the function is first tested:
IfpartialFunction.isDefinedAt(element)true, the element is mapped to typeR:R newElement = partialFunction.apply(element)Note: If this
Traversableis ordered (i.e., extendsOrdered), the caller must ensure that the resulting elements are comparable (i.e., implementComparable).- Specified by:
collectin interfaceSet<T>- Specified by:
collectin interfaceSortedSet<T>- Specified by:
collectin interfaceTraversable<T>- Type Parameters:
R- the type of elements in the resultingTraversable- Parameters:
partialFunction- a function that may not be defined for all elements of this traversable- Returns:
- a new
Traversablecontaining the results of applying the partial function
-
diff
Description copied from interface:SetReturns a new set containing all elements of this set except those in the given set. -
distinct
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance with all duplicates removed. Element equality is determined usingequals. -
distinctBy
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance without duplicates, as determined by the givencomparator.- Specified by:
distinctByin interfaceSet<T>- Specified by:
distinctByin interfaceSortedSet<T>- Specified by:
distinctByin interfaceTraversable<T>- Parameters:
comparator- a comparator used to determine equality of elements- Returns:
- a new
Traversablewith duplicates removed
-
distinctBy
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance without duplicates, based on keys extracted from elements usingkeyExtractor.The first occurrence of each key is retained in the resulting sequence.
- Specified by:
distinctByin interfaceSet<T>- Specified by:
distinctByin interfaceSortedSet<T>- Specified by:
distinctByin interfaceTraversable<T>- Type Parameters:
U- the type of key- Parameters:
keyExtractor- a function to extract keys for determining uniqueness- Returns:
- a new
Traversablewith duplicates removed based on keys
-
drop
Description copied from interface:TraversableReturns a newTraversablewithout the firstnelements, or an empty instance if this contains fewer thannelements. -
dropRight
Description copied from interface:TraversableReturns a newTraversablewithout the lastnelements, or an empty instance if this contains fewer thannelements. -
dropUntil
Description copied from interface:TraversableReturns a newTraversablestarting from the first element that satisfies the givenpredicate, dropping all preceding elements. -
dropWhile
Description copied from interface:TraversableReturns a newTraversablestarting from the first element that does not satisfy the givenpredicate, dropping all preceding elements.This is equivalent to
dropUntil(predicate.negate()), which is useful for method references that cannot be negated directly. -
filter
Description copied from interface:TraversableReturns a new traversable containing only the elements that satisfy the given predicate. -
reject
Description copied from interface:TraversableReturns a new traversable containing only the elements that do not satisfy the given predicate.This is equivalent to
filter(predicate.negate()). -
flatMap
default <U> SortedSet<U> flatMap(@NonNull Comparator<? super U> comparator, Function<? super T, ? extends Iterable<? extends U>> mapper) Description copied from interface:SortedSetSame asSortedSet.flatMap(Function)but using a specific comparator for values of the codomain of the givenmapper. -
flatMap
default <U> SortedSet<U> flatMap(@NonNull Function<? super T, ? extends Iterable<? extends U>> mapper) Description copied from interface:TraversableTransforms each element of this Traversable into anIterableof elements and flattens the resulting iterables into a single Traversable.- Specified by:
flatMapin interfaceSet<T>- Specified by:
flatMapin interfaceSortedSet<T>- Specified by:
flatMapin interfaceTraversable<T>- Type Parameters:
U- the type of elements in the resulting Traversable- Parameters:
mapper- a function mapping elements to iterables- Returns:
- a new Traversable containing all elements produced by applying
mapperand flattening
-
foldRight
Description copied from interface:FoldableFolds the elements of this structure from the right, starting with the givenzerovalue and successively applying thecombinefunction to each element.Folding from the right means that elements are combined starting from the last element and associating each step with the accumulated result so far.
Example:
// Result: "!cba" List.of("a", "b", "c").foldRight("!", (x, acc) -> acc + x);- Specified by:
foldRightin interfaceFoldable<T>- Specified by:
foldRightin interfaceTraversable<T>- Type Parameters:
U- the type of the accumulated result- Parameters:
zero- the initial value to start folding withf- a function that combines the next element and the accumulated value- Returns:
- the folded result
-
groupBy
Description copied from interface:TraversableGroups elements of thisTraversablebased on a classifier function.- Specified by:
groupByin interfaceSet<T>- Specified by:
groupByin interfaceSortedSet<T>- Specified by:
groupByin interfaceTraversable<T>- Type Parameters:
C- The type of the group keys- Parameters:
classifier- A function that assigns each element to a group- Returns:
- A map where each key corresponds to a group of elements
- See Also:
-
grouped
Description copied from interface:TraversableSplits thisTraversableinto consecutive blocks of the given size.Let
lengthbe the number of elements in thisTraversable:- If empty, the resulting
Iteratoris empty. - If
size <= length, the resultingIteratorcontainslength / sizeblocks of sizesizeand possibly a final smaller block of sizelength % size. - If
size > length, the resultingIteratorcontains a single block of sizelength.
Examples:
[].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]]Note:
grouped(size)is equivalent tosliding(size, size). - If empty, the resulting
-
hasDefiniteSize
default boolean hasDefiniteSize()Description copied from interface:TraversableIndicates whether thisTraversablehas a known finite size.This should typically be implemented by concrete classes, not interfaces.
- Specified by:
hasDefiniteSizein interfaceTraversable<T>- Returns:
trueif the number of elements is finite and known,falseotherwise.
-
init
Description copied from interface:TraversableReturns all elements of this Traversable except the last one.This is the dual of
Traversable.tail(). -
initOption
Description copied from interface:TraversableReturns all elements of this Traversable except the last one, wrapped in anOption.This is the dual of
Traversable.tailOption().- Specified by:
initOptionin interfaceSet<T>- Specified by:
initOptionin interfaceSortedSet<T>- Specified by:
initOptionin interfaceTraversable<T>- Returns:
Some(traversable)if non-empty, orNoneif this Traversable is empty
-
isAsync
-
isTraversableAgain
default boolean isTraversableAgain()Description copied from interface:TraversableChecks if this Traversable can be traversed multiple times without side effects.Implementations should provide the correct behavior; this is not meant for interfaces alone.
- Specified by:
isTraversableAgainin interfaceTraversable<T>- Returns:
trueif this Traversable is guaranteed to be repeatably traversable,falseotherwise
-
isLazy
-
intersect
Description copied from interface:SetReturns a new set containing only the elements present in both this set and the given set. -
last
Description copied from interface:TraversableReturns the last element of this Traversable.- Specified by:
lastin interfaceTraversable<T>- Returns:
- the last element
-
partition
Description copied from interface:TraversableSplits thisTraversableinto two partitions according to a predicate.The first partition contains all elements that satisfy the predicate, and the second contains all elements that do not. The original iteration order is preserved.
-
peek
Description copied from interface:ValuePerforms the givenactionon the first element if this is an eager implementation. Performs the givenactionon all elements (the first immediately, successive deferred), if this is a lazy implementation. -
stringPrefix
Description copied from interface:ValueReturns the name of this Value type, which is used by toString().- Specified by:
stringPrefixin interfaceValue<T>- Returns:
- This type name.
-
map
default <U> SortedSet<U> map(@NonNull Comparator<? super U> comparator, Function<? super T, ? extends U> mapper) Description copied from interface:SortedSetSame asSortedSet.map(Function)but using a specific comparator for values of the codomain of the givenmapper. -
map
Description copied from interface:TraversableTransforms the elements of this Traversable to a new type, preserving order if defined.- Specified by:
mapin interfaceSet<T>- Specified by:
mapin interfaceSortedSet<T>- Specified by:
mapin interfaceTraversable<T>- Specified by:
mapin interfaceValue<T>- Type Parameters:
U- the target element type- Parameters:
mapper- a mapping function- Returns:
- a new Traversable containing the mapped elements
-
mapTo
Description copied from interface:ValueMaps the underlying value to another fixed value. -
mapToVoid
Description copied from interface:ValueMaps the underlying value to Void -
remove
Description copied from interface:SetReturns a new set with the given element removed, if it was present. -
removeAll
Description copied from interface:SetReturns a new set with all given elements removed, if present. -
replace
Description copied from interface:TraversableReplaces the first occurrence ofcurrentElementwithnewElement, if it exists.- Specified by:
replacein interfaceSet<T>- Specified by:
replacein interfaceSortedSet<T>- Specified by:
replacein interfaceTraversable<T>- Parameters:
currentElement- the element to be replacednewElement- the replacement element- Returns:
- a new Traversable with the first occurrence of
currentElementreplaced bynewElement
-
replaceAll
Description copied from interface:TraversableReplaces all occurrences ofcurrentElementwithnewElement.- Specified by:
replaceAllin interfaceSet<T>- Specified by:
replaceAllin interfaceSortedSet<T>- Specified by:
replaceAllin interfaceTraversable<T>- Parameters:
currentElement- the element to be replacednewElement- the replacement element- Returns:
- a new Traversable with all occurrences of
currentElementreplaced bynewElement
-
retainAll
Description copied from interface:TraversableRetains only the elements from this Traversable that are contained in the givenelements. -
scan
Description copied from interface:TraversableComputes a prefix scan of the elements of this Traversable.The neutral element
zeromay be applied more than once. -
scanLeft
default <U> Set<U> scanLeft(U zero, @NonNull BiFunction<? super U, ? super T, ? extends U> operation) Description copied from interface:TraversableProduces a collection containing cumulative results of applying the operator from left to right.Will not terminate for infinite collections. The results may vary across runs unless the collection is ordered.
- Specified by:
scanLeftin interfaceSet<T>- Specified by:
scanLeftin interfaceSortedSet<T>- Specified by:
scanLeftin interfaceTraversable<T>- Type Parameters:
U- the type of the resulting elements- Parameters:
zero- the initial valueoperation- a binary operator applied to the intermediate result and each element- Returns:
- a new Traversable containing the cumulative results
-
scanRight
default <U> Set<U> scanRight(U zero, @NonNull BiFunction<? super T, ? super U, ? extends U> operation) Description copied from interface:TraversableProduces a collection containing cumulative results of applying the operator from right to left.The head of the resulting collection is the last cumulative result. Will not terminate for infinite collections. Results may vary across runs unless the collection is ordered.
- Specified by:
scanRightin interfaceSet<T>- Specified by:
scanRightin interfaceSortedSet<T>- Specified by:
scanRightin interfaceTraversable<T>- Type Parameters:
U- the type of the resulting elements- Parameters:
zero- the initial valueoperation- a binary operator applied to each element and the intermediate result- Returns:
- a new Traversable containing the cumulative results
-
slideBy
Description copied from interface:TraversablePartitions thisTraversableinto consecutive non-overlapping windows according to a classification function.Each window contains elements with the same class, as determined by
classifier. Two consecutive elements belong to the same window only ifclassifierreturns equal values for both. Otherwise, the current window ends and a new window begins with the next element.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]] -
sliding
Description copied from interface:TraversableSlides a window of a givensizeover thisTraversablewith a step size of 1.This is equivalent to calling
Traversable.sliding(int, int)with a step size of 1. -
sliding
Description copied from interface:TraversableSlides a window of a specificsizewith a givenstepover thisTraversable.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]] -
span
Description copied from interface:TraversableSplits thisTraversableinto a prefix and remainder according to the givenpredicate.The first element of the returned
Tupleis the longest prefix of elements satisfyingpredicate, and the second element is the remaining elements. -
tail
Description copied from interface:TraversableReturns a newTraversablewithout its first element. -
tailOption
Description copied from interface:TraversableReturns a newTraversablewithout its first element as anOption.- Specified by:
tailOptionin interfaceSet<T>- Specified by:
tailOptionin interfaceSortedSet<T>- Specified by:
tailOptionin interfaceTraversable<T>- Returns:
Some(traversable)if non-empty, otherwiseNone
-
take
Description copied from interface:TraversableReturns the firstnelements of thisTraversable, or all elements ifnexceeds the length.Equivalent to
sublist(0, max(0, min(length(), n))), but safe forn < 0orn > length().If
n < 0, an empty instance is returned. Ifn > length(), the full instance is returned. -
takeRight
Description copied from interface:TraversableReturns the lastnelements of thisTraversable, or all elements ifnexceeds the length.Equivalent to
sublist(max(0, length() - n), length()), but safe forn < 0orn > length().If
n < 0, an empty instance is returned. Ifn > length(), the full instance is returned. -
takeUntil
Description copied from interface:TraversableTakes elements from thisTraversableuntil the given predicate holds for an element.Equivalent to
takeWhile(predicate.negate()), but useful when using method references that cannot be negated directly.- Specified by:
takeUntilin interfaceSet<T>- Specified by:
takeUntilin interfaceSortedSet<T>- Specified by:
takeUntilin interfaceTraversable<T>- Parameters:
predicate- a condition tested sequentially on the elements- Returns:
- a new
Traversablecontaining all elements before the first one that satisfies the predicate
-
takeWhile
Description copied from interface:TraversableTakes elements from thisTraversablewhile the given predicate holds.- Specified by:
takeWhilein interfaceSet<T>- Specified by:
takeWhilein interfaceSortedSet<T>- Specified by:
takeWhilein interfaceTraversable<T>- Parameters:
predicate- a condition tested sequentially on the elements- Returns:
- a new
Traversablecontaining all elements up to (but not including) the first one that does not satisfy the predicate
-
toJavaSet
Description copied from interface:SetConverts this Vavr set to ajava.util.Set, preserving insertion or sort order. -
union
Description copied from interface:SetReturns a new set containing all distinct elements from this set and the given set. -
unzip
default <T1,T2> Tuple2<TreeSet<T1>, TreeSet<T2>> unzip(@NonNull Function<? super T, Tuple2<? extends T1, ? extends T2>> unzipper) Description copied from interface:TraversableUnzips the elements of thisTraversableby mapping each element to a pair and splitting them into two separateTraversablecollections.- Specified by:
unzipin interfaceSet<T>- Specified by:
unzipin interfaceSortedSet<T>- Specified by:
unzipin interfaceTraversable<T>- Type Parameters:
T1- type of the first element in the resulting pairsT2- type of the second element in the resulting pairs- Parameters:
unzipper- a function that maps elements of thisTraversableto pairs- Returns:
- a
Tuple2containing twoTraversablecollections with the split elements
-
unzip3
default <T1,T2, Tuple3<TreeSet<T1>, TreeSet<T2>, TreeSet<T3>> unzip3T3> (@NonNull Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) Description copied from interface:TraversableUnzips the elements of thisTraversableby mapping each element to a triple and splitting them into three separateTraversablecollections.- Specified by:
unzip3in interfaceSet<T>- Specified by:
unzip3in interfaceSortedSet<T>- Specified by:
unzip3in interfaceTraversable<T>- Type Parameters:
T1- type of the first element in the resulting triplesT2- type of the second element in the resulting triplesT3- type of the third element in the resulting triples- Parameters:
unzipper- a function that maps elements of thisTraversableto triples- Returns:
- a
Tuple3containing threeTraversablecollections with the split elements
-
zip
Description copied from interface:TraversableReturns aTraversableformed by pairing elements of thisTraversablewith elements of anotherIterable. Pairing stops when either collection runs out of elements; any remaining elements in the longer collection are ignored.The length of the resulting
Traversableis the minimum of the lengths of thisTraversableandthat.- Specified by:
zipin interfaceSet<T>- Specified by:
zipin interfaceSortedSet<T>- Specified by:
zipin interfaceTraversable<T>- Type Parameters:
U- the type of elements in the second half of each pair- Parameters:
that- anIterableproviding the second element of each pair- Returns:
- a new
Traversablecontaining pairs of corresponding elements
-
zipWith
default <U,R> TreeSet<R> zipWith(@NonNull Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) Description copied from interface:TraversableReturns aTraversableby combining elements of thisTraversablewith elements of anotherIterableusing a mapping function. Pairing stops when either collection runs out of elements.The length of the resulting
Traversableis the minimum of the lengths of thisTraversableandthat.- Specified by:
zipWithin interfaceSet<T>- Specified by:
zipWithin interfaceSortedSet<T>- Specified by:
zipWithin interfaceTraversable<T>- Type Parameters:
U- the type of elements in the second parameter of the mapperR- the type of elements in the resultingTraversable- Parameters:
that- anIterableproviding the second parameter of the mappermapper- a function that combines elements from this andthatinto a new element- Returns:
- a new
Traversablecontaining mapped elements
-
zipAll
default <U> TreeSet<Tuple2<T,U>> zipAll(@NonNull Iterable<? extends U> that, T thisElem, U thatElem) Description copied from interface:TraversableReturns aTraversableformed by pairing elements of thisTraversablewith elements of anotherIterable, filling in placeholder elements when one collection is shorter than the other.The length of the resulting
Traversableis the maximum of the lengths of thisTraversableandthat.If this
Traversableis shorter thanthat,thisElemis used as a filler. Conversely, ifthatis shorter,thatElemis used.- Specified by:
zipAllin interfaceSet<T>- Specified by:
zipAllin interfaceSortedSet<T>- Specified by:
zipAllin interfaceTraversable<T>- Type Parameters:
U- the type of elements in the second half of each pair- Parameters:
that- anIterableproviding the second element of each pairthisElem- the element used to fill missing values if thisTraversableis shorter thanthatthatElem- the element used to fill missing values ifthatis shorter than thisTraversable- Returns:
- a new
Traversablecontaining pairs of elements, including fillers as needed
-
zipWithIndex
Description copied from interface:TraversableZips thisTraversablewith its indices, starting at 0.- Specified by:
zipWithIndexin interfaceSet<T>- Specified by:
zipWithIndexin interfaceSortedSet<T>- Specified by:
zipWithIndexin interfaceTraversable<T>- Returns:
- a new
Traversablecontaining each element paired with its index
-
zipWithIndex
default <U> TreeSet<U> zipWithIndex(@NonNull BiFunction<? super T, ? super Integer, ? extends U> mapper) Description copied from interface:TraversableZips thisTraversablewith its indices and maps the resulting pairs using the provided mapper.- Specified by:
zipWithIndexin interfaceSet<T>- Specified by:
zipWithIndexin interfaceSortedSet<T>- Specified by:
zipWithIndexin interfaceTraversable<T>- Type Parameters:
U- the type of elements in the resultingTraversable- Parameters:
mapper- a function mapping an element and its index to a new element- Returns:
- a new
Traversablecontaining the mapped elements
-