Interface SortedSet<T>
-
- Type Parameters:
T- Component type
- All Superinterfaces:
Foldable<T>,java.util.function.Function<T,java.lang.Boolean>,Function1<T,java.lang.Boolean>,java.lang.Iterable<T>,Ordered<T>,java.io.Serializable,Set<T>,Traversable<T>,Value<T>
- All Known Subinterfaces:
BitSet<T>
- All Known Implementing Classes:
BitSetModule.AbstractBitSet,BitSetModule.BitSet1,BitSetModule.BitSet2,BitSetModule.BitSetN,TreeSet
public interface SortedSet<T> extends Set<T>, Ordered<T>
An immutableSortedSetinterface.Specific SortedSet operations:
-
-
Field Summary
Fields Modifier and Type Field Description static longserialVersionUIDThe serial version UID for serialization.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description SortedSet<T>add(T element)Returns a new set containing all elements of this set plus the given element, if it was not already present.SortedSet<T>addAll(@NonNull java.lang.Iterable<? extends T> elements)Returns a new set containing all elements of this set plus the given elements, excluding duplicates.<R> SortedSet<R>collect(@NonNull PartialFunction<? super T,? extends R> partialFunction)Applies aPartialFunctionto all elements that are defined for it and collects the results.SortedSet<T>diff(@NonNull Set<? extends T> elements)Returns a new set containing all elements of this set except those in the given set.SortedSet<T>distinct()Returns a newTraversablecontaining the elements of this instance with all duplicates removed.SortedSet<T>distinctBy(@NonNull java.util.Comparator<? super T> comparator)Returns a newTraversablecontaining the elements of this instance without duplicates, as determined by the givencomparator.<U> SortedSet<T>distinctBy(@NonNull java.util.function.Function<? super T,? extends U> keyExtractor)Returns a newTraversablecontaining the elements of this instance without duplicates, based on keys extracted from elements usingkeyExtractor.SortedSet<T>drop(int n)Returns a newTraversablewithout the firstnelements, or an empty instance if this contains fewer thannelements.SortedSet<T>dropRight(int n)Returns a newTraversablewithout the lastnelements, or an empty instance if this contains fewer thannelements.SortedSet<T>dropUntil(@NonNull java.util.function.Predicate<? super T> predicate)Returns a newTraversablestarting from the first element that satisfies the givenpredicate, dropping all preceding elements.SortedSet<T>dropWhile(@NonNull java.util.function.Predicate<? super T> predicate)Returns a newTraversablestarting from the first element that does not satisfy the givenpredicate, dropping all preceding elements.SortedSet<T>filter(@NonNull java.util.function.Predicate<? super T> predicate)Returns a new traversable containing only the elements that satisfy the given predicate.<U> SortedSet<U>flatMap(@NonNull java.util.Comparator<? super U> comparator, java.util.function.Function<? super T,? extends java.lang.Iterable<? extends U>> mapper)Same asflatMap(Function)but using a specific comparator for values of the codomain of the givenmapper.<U> SortedSet<U>flatMap(@NonNull java.util.function.Function<? super T,? extends java.lang.Iterable<? extends U>> mapper)Transforms each element of this Traversable into anIterableof elements and flattens the resulting iterables into a single Traversable.<C> Map<C,? extends SortedSet<T>>groupBy(@NonNull java.util.function.Function<? super T,? extends C> classifier)Groups elements of thisTraversablebased on a classifier function.Iterator<? extends SortedSet<T>>grouped(int size)Splits thisTraversableinto consecutive blocks of the given size.SortedSet<T>init()Returns all elements of this Traversable except the last one.Option<? extends SortedSet<T>>initOption()Returns all elements of this Traversable except the last one, wrapped in anOption.SortedSet<T>intersect(@NonNull Set<? extends T> elements)Returns a new set containing only the elements present in both this set and the given set.default booleanisOrdered()Indicates whether this Traversable is ordered according to its natural or specified order.<U> SortedSet<U>map(@NonNull java.util.Comparator<? super U> comparator, java.util.function.Function<? super T,? extends U> mapper)Same asmap(Function)but using a specific comparator for values of the codomain of the givenmapper.<U> SortedSet<U>map(@NonNull java.util.function.Function<? super T,? extends U> mapper)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.default SortedSet<java.lang.Void>mapToVoid()Maps the underlying value to Voidstatic <T> SortedSet<T>narrow(SortedSet<? extends T> sortedSet)Narrows a widenedSortedSet<? extends T>toSortedSet<T>by performing a type-safe cast.SortedSet<T>orElse(@NonNull java.lang.Iterable<? extends T> other)Returns thisTraversableif it is non-empty; otherwise, returns the given alternative.SortedSet<T>orElse(@NonNull java.util.function.Supplier<? extends java.lang.Iterable<? extends T>> supplier)Returns thisTraversableif it is non-empty; otherwise, returns the result of evaluating the given supplier.Tuple2<? extends SortedSet<T>,? extends SortedSet<T>>partition(@NonNull java.util.function.Predicate<? super T> predicate)Splits thisTraversableinto two partitions according to a predicate.SortedSet<T>peek(@NonNull java.util.function.Consumer<? super T> action)Performs the givenactionon the first element if this is an eager implementation.SortedSet<T>reject(@NonNull java.util.function.Predicate<? super T> predicate)Returns a new traversable containing only the elements that do not satisfy the given predicate.SortedSet<T>remove(T element)Returns a new set with the given element removed, if it was present.SortedSet<T>removeAll(@NonNull java.lang.Iterable<? extends T> elements)Returns a new set with all given elements removed, if present.SortedSet<T>replace(T currentElement, T newElement)Replaces the first occurrence ofcurrentElementwithnewElement, if it exists.SortedSet<T>replaceAll(T currentElement, T newElement)Replaces all occurrences ofcurrentElementwithnewElement.SortedSet<T>retainAll(@NonNull java.lang.Iterable<? extends T> elements)Retains only the elements from this Traversable that are contained in the givenelements.SortedSet<T>scan(T zero, @NonNull java.util.function.BiFunction<? super T,? super T,? extends T> operation)Computes a prefix scan of the elements of this Traversable.<U> Set<U>scanLeft(U zero, @NonNull java.util.function.BiFunction<? super U,? super T,? extends U> operation)Produces a collection containing cumulative results of applying the operator from left to right.<U> Set<U>scanRight(U zero, @NonNull java.util.function.BiFunction<? super T,? super U,? extends U> operation)Produces a collection containing cumulative results of applying the operator from right to left.Iterator<? extends SortedSet<T>>slideBy(@NonNull java.util.function.Function<? super T,?> classifier)Partitions thisTraversableinto consecutive non-overlapping windows according to a classification function.Iterator<? extends SortedSet<T>>sliding(int size)Slides a window of a givensizeover thisTraversablewith a step size of 1.Iterator<? extends SortedSet<T>>sliding(int size, int step)Slides a window of a specificsizewith a givenstepover thisTraversable.Tuple2<? extends SortedSet<T>,? extends SortedSet<T>>span(@NonNull java.util.function.Predicate<? super T> predicate)Splits thisTraversableinto a prefix and remainder according to the givenpredicate.SortedSet<T>tail()Returns a newTraversablewithout its first element.Option<? extends SortedSet<T>>tailOption()Returns a newTraversablewithout its first element as anOption.SortedSet<T>take(int n)Returns the firstnelements of thisTraversable, or all elements ifnexceeds the length.SortedSet<T>takeRight(int n)Returns the lastnelements of thisTraversable, or all elements ifnexceeds the length.SortedSet<T>takeUntil(@NonNull java.util.function.Predicate<? super T> predicate)Takes elements from thisTraversableuntil the given predicate holds for an element.SortedSet<T>takeWhile(@NonNull java.util.function.Predicate<? super T> predicate)Takes elements from thisTraversablewhile the given predicate holds.java.util.SortedSet<T>toJavaSet()Converts this Vavr set to ajava.util.Set, preserving insertion or sort order.SortedSet<T>union(@NonNull Set<? extends T> elements)Returns a new set containing all distinct elements from this set and the given set.<T1,T2>
Tuple2<? extends SortedSet<T1>,? extends SortedSet<T2>>unzip(@NonNull java.util.function.Function<? super T,Tuple2<? extends T1,? extends T2>> unzipper)Unzips the elements of thisTraversableby mapping each element to a pair and splitting them into two separateTraversablecollections.<T1,T2,T3>
Tuple3<? extends SortedSet<T1>,? extends SortedSet<T2>,? extends SortedSet<T3>>unzip3(@NonNull java.util.function.Function<? super T,Tuple3<? extends T1,? extends T2,? extends T3>> unzipper)Unzips the elements of thisTraversableby mapping each element to a triple and splitting them into three separateTraversablecollections.<U> SortedSet<Tuple2<T,U>>zip(@NonNull java.lang.Iterable<? extends U> that)Returns aTraversableformed by pairing elements of thisTraversablewith elements of anotherIterable.<U> SortedSet<Tuple2<T,U>>zipAll(@NonNull java.lang.Iterable<? extends U> that, T thisElem, U thatElem)Returns aTraversableformed by pairing elements of thisTraversablewith elements of anotherIterable, filling in placeholder elements when one collection is shorter than the other.<U,R>
SortedSet<R>zipWith(@NonNull java.lang.Iterable<? extends U> that, java.util.function.BiFunction<? super T,? super U,? extends R> mapper)Returns aTraversableby combining elements of thisTraversablewith elements of anotherIterableusing a mapping function.SortedSet<Tuple2<T,java.lang.Integer>>zipWithIndex()Zips thisTraversablewith its indices, starting at 0.<U> SortedSet<U>zipWithIndex(@NonNull java.util.function.BiFunction<? super T,? super java.lang.Integer,? extends U> mapper)Zips thisTraversablewith its indices and maps the resulting pairs using the provided mapper.-
Methods inherited from interface io.vavr.collection.Foldable
fold, reduce, reduceOption
-
Methods inherited from interface io.vavr.Function1
andThen, arity, compose, compose1, curried, isMemoized, memoized, partial, reversed, tupled
-
Methods inherited from interface io.vavr.collection.Ordered
comparator
-
Methods inherited from interface io.vavr.collection.Set
apply, contains, isDistinct, iterator, length
-
Methods inherited from interface io.vavr.collection.Traversable
arrangeBy, average, containsAll, count, equals, existsUnique, find, findLast, foldLeft, foldRight, forEachWithIndex, get, hasDefiniteSize, hashCode, head, headOption, isEmpty, isSequential, isSingleValued, isTraversableAgain, last, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, single, singleOption, size, spliterator, sum
-
Methods inherited from interface io.vavr.Value
collect, collect, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, isAsync, isLazy, out, out, stderr, stdout, stringPrefix, 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 Detail
-
serialVersionUID
static final long serialVersionUID
The serial version UID for serialization.- See Also:
- Constant Field Values
-
-
Method Detail
-
narrow
static <T> SortedSet<T> narrow(SortedSet<? extends T> sortedSet)
Narrows a widenedSortedSet<? extends T>toSortedSet<T>by performing a type-safe cast. This is eligible because immutable/read-only collections are covariant.CAUTION: The underlying
Comparatormight fail!- Type Parameters:
T- Component type of theSortedSet.- Parameters:
sortedSet- ASortedSet.- Returns:
- the given
sortedSetinstance as narrowed typeSortedSet<T>.
-
flatMap
<U> SortedSet<U> flatMap(@NonNull java.util.Comparator<? super U> comparator, java.util.function.Function<? super T,? extends java.lang.Iterable<? extends U>> mapper)
Same asflatMap(Function)but using a specific comparator for values of the codomain of the givenmapper.- Type Parameters:
U- Type of flat-mapped values- Parameters:
comparator- A comparator for values of type Umapper- A function which maps values of type T to Iterables of values of type U- Returns:
- A new Set instance containing mapped values
-
map
<U> SortedSet<U> map(@NonNull java.util.Comparator<? super U> comparator, java.util.function.Function<? super T,? extends U> mapper)
Same asmap(Function)but using a specific comparator for values of the codomain of the givenmapper.- Type Parameters:
U- Type of mapped values- Parameters:
comparator- A comparator for values of type Umapper- A function which maps values of type T to values of type U- Returns:
- A new Set instance containing mapped values
-
add
SortedSet<T> add(T element)
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
SortedSet<T> addAll(@NonNull java.lang.Iterable<? extends T> elements)
Description copied from interface:SetReturns a new set containing all elements of this set plus the given elements, excluding duplicates.
-
collect
<R> SortedSet<R> collect(@NonNull PartialFunction<? super T,? extends R> partialFunction)
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 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
SortedSet<T> diff(@NonNull Set<? extends T> elements)
Description copied from interface:SetReturns a new set containing all elements of this set except those in the given set.
-
distinct
SortedSet<T> distinct()
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance with all duplicates removed. Element equality is determined usingequals.
-
distinctBy
SortedSet<T> distinctBy(@NonNull java.util.Comparator<? super T> comparator)
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 interfaceTraversable<T>- Parameters:
comparator- a comparator used to determine equality of elements- Returns:
- a new
Traversablewith duplicates removed
-
distinctBy
<U> SortedSet<T> distinctBy(@NonNull java.util.function.Function<? super T,? extends U> keyExtractor)
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 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
SortedSet<T> drop(int n)
Description copied from interface:TraversableReturns a newTraversablewithout the firstnelements, or an empty instance if this contains fewer thannelements.
-
dropRight
SortedSet<T> dropRight(int n)
Description copied from interface:TraversableReturns a newTraversablewithout the lastnelements, or an empty instance if this contains fewer thannelements.
-
dropUntil
SortedSet<T> dropUntil(@NonNull java.util.function.Predicate<? super T> predicate)
Description copied from interface:TraversableReturns a newTraversablestarting from the first element that satisfies the givenpredicate, dropping all preceding elements.
-
dropWhile
SortedSet<T> dropWhile(@NonNull java.util.function.Predicate<? super T> predicate)
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
SortedSet<T> filter(@NonNull java.util.function.Predicate<? super T> predicate)
Description copied from interface:TraversableReturns a new traversable containing only the elements that satisfy the given predicate.
-
reject
SortedSet<T> reject(@NonNull java.util.function.Predicate<? super T> predicate)
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
<U> SortedSet<U> flatMap(@NonNull java.util.function.Function<? super T,? extends java.lang.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 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
-
groupBy
<C> Map<C,? extends SortedSet<T>> groupBy(@NonNull java.util.function.Function<? super T,? extends C> classifier)
Description copied from interface:TraversableGroups elements of thisTraversablebased on a classifier function.- Specified by:
groupByin interfaceSet<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:
Traversable.arrangeBy(Function)
-
grouped
Iterator<? extends SortedSet<T>> grouped(int size)
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
-
init
SortedSet<T> init()
Description copied from interface:TraversableReturns all elements of this Traversable except the last one.This is the dual of
Traversable.tail().
-
initOption
Option<? extends SortedSet<T>> 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 interfaceTraversable<T>- Returns:
Some(traversable)if non-empty, orNoneif this Traversable is empty
-
intersect
SortedSet<T> intersect(@NonNull Set<? extends T> elements)
Description copied from interface:SetReturns a new set containing only the elements present in both this set and the given set.
-
isOrdered
default boolean isOrdered()
Description copied from interface:TraversableIndicates whether this Traversable is ordered according to its natural or specified order.- Specified by:
isOrderedin interfaceTraversable<T>- Returns:
trueif this Traversable is ordered,falseotherwise
-
map
<U> SortedSet<U> map(@NonNull java.util.function.Function<? super T,? extends U> mapper)
Description copied from interface:TraversableTransforms the elements of this Traversable to a new type, preserving order if defined.
-
mapTo
default <U> SortedSet<U> mapTo(U value)
Description copied from interface:ValueMaps the underlying value to another fixed value.
-
mapToVoid
default SortedSet<java.lang.Void> mapToVoid()
Description copied from interface:ValueMaps the underlying value to Void
-
orElse
SortedSet<T> orElse(@NonNull java.lang.Iterable<? extends T> other)
Description copied from interface:TraversableReturns thisTraversableif it is non-empty; otherwise, returns the given alternative.
-
orElse
SortedSet<T> orElse(@NonNull java.util.function.Supplier<? extends java.lang.Iterable<? extends T>> supplier)
Description copied from interface:TraversableReturns thisTraversableif it is non-empty; otherwise, returns the result of evaluating the given supplier.
-
partition
Tuple2<? extends SortedSet<T>,? extends SortedSet<T>> partition(@NonNull java.util.function.Predicate<? super T> predicate)
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
SortedSet<T> peek(@NonNull java.util.function.Consumer<? super T> action)
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.
-
remove
SortedSet<T> remove(T element)
Description copied from interface:SetReturns a new set with the given element removed, if it was present.
-
removeAll
SortedSet<T> removeAll(@NonNull java.lang.Iterable<? extends T> elements)
Description copied from interface:SetReturns a new set with all given elements removed, if present.
-
replace
SortedSet<T> replace(T currentElement, T newElement)
Description copied from interface:TraversableReplaces the first occurrence ofcurrentElementwithnewElement, if it exists.
-
replaceAll
SortedSet<T> replaceAll(T currentElement, T newElement)
Description copied from interface:TraversableReplaces all occurrences ofcurrentElementwithnewElement.- Specified by:
replaceAllin interfaceSet<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
SortedSet<T> retainAll(@NonNull java.lang.Iterable<? extends T> elements)
Description copied from interface:TraversableRetains only the elements from this Traversable that are contained in the givenelements.
-
scan
SortedSet<T> scan(T zero, @NonNull java.util.function.BiFunction<? super T,? super T,? extends T> operation)
Description copied from interface:TraversableComputes a prefix scan of the elements of this Traversable.The neutral element
zeromay be applied more than once.
-
scanLeft
<U> Set<U> scanLeft(U zero, @NonNull java.util.function.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 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
<U> Set<U> scanRight(U zero, @NonNull java.util.function.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 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
Iterator<? extends SortedSet<T>> slideBy(@NonNull java.util.function.Function<? super T,?> classifier)
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
Iterator<? extends SortedSet<T>> sliding(int size)
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
Iterator<? extends SortedSet<T>> sliding(int size, int step)
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
Tuple2<? extends SortedSet<T>,? extends SortedSet<T>> span(@NonNull java.util.function.Predicate<? super T> predicate)
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
SortedSet<T> tail()
Description copied from interface:TraversableReturns a newTraversablewithout its first element.
-
tailOption
Option<? extends SortedSet<T>> tailOption()
Description copied from interface:TraversableReturns a newTraversablewithout its first element as anOption.- Specified by:
tailOptionin interfaceSet<T>- Specified by:
tailOptionin interfaceTraversable<T>- Returns:
Some(traversable)if non-empty, otherwiseNone
-
take
SortedSet<T> take(int n)
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
SortedSet<T> takeRight(int n)
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
SortedSet<T> takeUntil(@NonNull java.util.function.Predicate<? super T> predicate)
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.
-
takeWhile
SortedSet<T> takeWhile(@NonNull java.util.function.Predicate<? super T> predicate)
Description copied from interface:TraversableTakes elements from thisTraversablewhile the given predicate holds.
-
toJavaSet
java.util.SortedSet<T> toJavaSet()
Description copied from interface:SetConverts this Vavr set to ajava.util.Set, preserving insertion or sort order.
-
union
SortedSet<T> union(@NonNull Set<? extends T> elements)
Description copied from interface:SetReturns a new set containing all distinct elements from this set and the given set.
-
unzip
<T1,T2> Tuple2<? extends SortedSet<T1>,? extends SortedSet<T2>> unzip(@NonNull java.util.function.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 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
<T1,T2,T3> Tuple3<? extends SortedSet<T1>,? extends SortedSet<T2>,? extends SortedSet<T3>> unzip3(@NonNull java.util.function.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 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
<U> SortedSet<Tuple2<T,U>> zip(@NonNull java.lang.Iterable<? extends U> that)
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 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
<U,R> SortedSet<R> zipWith(@NonNull java.lang.Iterable<? extends U> that, java.util.function.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 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
<U> SortedSet<Tuple2<T,U>> zipAll(@NonNull java.lang.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 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
SortedSet<Tuple2<T,java.lang.Integer>> zipWithIndex()
Description copied from interface:TraversableZips thisTraversablewith its indices, starting at 0.- Specified by:
zipWithIndexin interfaceSet<T>- Specified by:
zipWithIndexin interfaceTraversable<T>- Returns:
- a new
Traversablecontaining each element paired with its index
-
zipWithIndex
<U> SortedSet<U> zipWithIndex(@NonNull java.util.function.BiFunction<? super T,? super java.lang.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 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
-
-