Top Description Fields Methods
io.vavr.collection

public Interface IndexedSeq<T>

Additional top-level class in compilation unit: IndexedSeqModule.

extends Seq<T>
Known Direct Implementers
io.vavr.collection.Vector, io.vavr.collection.Array, io.vavr.collection.CharSeq
Type Parameters
<T>
component type
Imports
io.vavr.PartialFunction, .Tuple3, .Tuple2, io.vavr.control.Option, java.util.Comparator, .NoSuchElementException, .Objects, java.util.function.*

Interface for immutable, indexed sequences.

Efficient random access is characteristic for indexed sequences.

Author
Daniel Dietrich

Field Summary

Modifier and TypeField and Description
public static final long

Method Summary

Modifier and TypeMethod and Description
public IndexedSeq<T>
append(T
An element
element
)

Redeclares io.vavr.collection.Seq.append.

Appends an element to this.

public IndexedSeq<T>
appendAll(Iterable<? extends T>
An Iterable of elements
elements
)

Redeclares io.vavr.collection.Seq.appendAll.

Appends all given elements to this.

public IndexedSeq<T>
asJava(Consumer<? super List<T>>
A side-effecting unit of work that operates on an immutable java.util.List view.
action
)

Redeclares io.vavr.collection.Seq.asJava.

Creates an immutable java.util.List view on top of this Seq that is passed to the given action.

public IndexedSeq<T>
asJavaMutable(Consumer<? super List<T>>
A side-effecting unit of work that operates on a mutable java.util.List view.
action
)

Redeclares io.vavr.collection.Seq.asJavaMutable.

Creates a mutable java.util.List view on top of this Seq that is passed to the given action.

public default PartialFunction<Integer, T>
asPartialFunction()

Implements io.vavr.collection.Seq.asPartialFunction.

Turns this Seq into a PartialFunction which is defined at a specific index, if this Seq contains at least index + 1 elements.

public <R> IndexedSeq<R>
collect(PartialFunction<? super T, ? extends R>
A function that is not necessarily defined of all elements of this traversable.
partialFunction
)

Redeclares io.vavr.collection.Seq.collect.

Collects all elements that are in the domain of the given partialFunction by mapping the elements to type R.

public IndexedSeq<? extends IndexedSeq<T>>
combinations()

Redeclares io.vavr.collection.Seq.combinations.

Returns the union of all combinations from k = 0 to length().

public IndexedSeq<? extends IndexedSeq<T>>
combinations(int
Size of subsets
k
)

Redeclares io.vavr.collection.Seq.combinations.

Returns the k-combination of this traversable, i.e. all subset of this of k distinct elements.

public Iterator<? extends IndexedSeq<T>>
crossProduct(int
the number of cartesian multiplications
power
)

Redeclares io.vavr.collection.Seq.crossProduct.

Calculates the n-ary cartesian power (or cross product or simply product) of this.

public IndexedSeq<T>
distinct()

Redeclares io.vavr.collection.Seq.distinct.

Returns a new version of this which contains no duplicates.

public IndexedSeq<T>
distinctBy(Comparator<? super T>
A comparator
comparator
)

Redeclares io.vavr.collection.Seq.distinctBy.

Returns a new version of this which contains no duplicates.

public <U> IndexedSeq<T>
distinctBy(Function<? super T, ? extends U>
A key extractor
keyExtractor
)

Redeclares io.vavr.collection.Seq.distinctBy.

Returns a new version of this which contains no duplicates.

public IndexedSeq<T>
drop(int
The number of elements to drop.
n
)

Redeclares io.vavr.collection.Seq.drop.

Drops the first n elements of this or all elements, if this length < n.

public IndexedSeq<T>
dropRight(int
The number of elements to drop.
n
)

Redeclares io.vavr.collection.Seq.dropRight.

Drops the last n elements of this or all elements, if this length < n.

public IndexedSeq<T>
dropRightUntil(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Redeclares io.vavr.collection.Seq.dropRightUntil.

Drops elements until the predicate holds for the current element, starting from the end.

public IndexedSeq<T>
dropRightWhile(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Redeclares io.vavr.collection.Seq.dropRightWhile.

Drops elements while the predicate holds for the current element, starting from the end.

public IndexedSeq<T>
dropUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Redeclares io.vavr.collection.Seq.dropUntil.

Drops elements until the predicate holds for the current element.

public IndexedSeq<T>
dropWhile(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Redeclares io.vavr.collection.Seq.dropWhile.

Drops elements while the predicate holds for the current element.

public default boolean
endsWith(Seq<? extends T>
the sequence to test
that
)

Overrides default io.vavr.collection.Seq.endsWith.

Tests whether this sequence ends with the given sequence.

public IndexedSeq<T>
filter(Predicate<? super T>
A predicate
predicate
)

Redeclares io.vavr.collection.Seq.filter.

Returns a new traversable consisting of all elements which satisfy the given predicate.

public <U> IndexedSeq<U>
flatMap(Function<? super T, ? extends Iterable<? extends U>>
A mapper
mapper
)

Redeclares io.vavr.collection.Seq.flatMap.

FlatMaps this Traversable.

public <C> Map<C, ? extends IndexedSeq<T>>
groupBy(Function<? super T, ? extends C>
A function which classifies elements into classes
classifier
)

Redeclares io.vavr.collection.Seq.groupBy.

Groups this elements by classifying the elements.

public Iterator<? extends IndexedSeq<T>>
grouped(int
a positive block size
size
)

Redeclares io.vavr.collection.Seq.grouped.

Groups this Traversable into fixed size blocks.

public default int
indexOfSlice(Iterable<? extends T>
the sequence to test
that
,
int
the start index
from
)

Implements io.vavr.collection.Seq.indexOfSlice.

Finds first index after or at a start index where this sequence contains a given sequence as a slice.

public default int
indexWhere(Predicate<? super T>
the predicate used to test elements.
predicate
,
int
the start index
from
)

Implements io.vavr.collection.Seq.indexWhere.

Finds index of the first element satisfying some predicate after or at some start index.

public IndexedSeq<T>
init()

Redeclares io.vavr.collection.Seq.init.

Dual of tail(), returning all elements except the last.

public Option<? extends IndexedSeq<T>>
initOption()

Redeclares io.vavr.collection.Seq.initOption.

Dual of tailOption(), returning all elements except the last as Option.

public IndexedSeq<T>
insert(int
an index
index
,
T
an element
element
)

Redeclares io.vavr.collection.Seq.insert.

Inserts the given element at the specified index.

public IndexedSeq<T>
insertAll(int
an index
index
,
Iterable<? extends T>
An Iterable of elements
elements
)

Redeclares io.vavr.collection.Seq.insertAll.

Inserts the given elements at the specified index.

public IndexedSeq<T>
intersperse(T
An element.
element
)

Redeclares io.vavr.collection.Seq.intersperse.

Inserts an element between all elements of this Traversable.

public default boolean
isDefinedAt(Integer
a potential function argument
index
)

Implements io.vavr.PartialFunction.isDefinedAt.

Deprecated

Tests if a value is contained in the function's domain.

public default T
last()

Implements io.vavr.collection.Traversable.last.

Dual of head(), returning the last element.

public default int
lastIndexOfSlice(Iterable<? extends T>
the sequence to test
that
,
int
the end index
end
)

Implements io.vavr.collection.Seq.lastIndexOfSlice.

Finds last index before or at a given end index where this sequence contains a given sequence as a slice.

public default int
lastIndexWhere(Predicate<? super T>
the predicate used to test elements.
predicate
,
int
the maximum index of the search
end
)

Implements io.vavr.collection.Seq.lastIndexWhere.

Finds index of last element satisfying some predicate before or at given end index.

public <U> IndexedSeq<U>
map(Function<? super T, ? extends U>
A mapper.
mapper
)

Redeclares io.vavr.collection.Seq.map.

Maps the elements of this Traversable to elements of a new type preserving their order, if any.

public static <
Component type of the IndexedSeq.
T
>
IndexedSeq<T>

Returns:

the given indexedSeq instance as narrowed type IndexedSeq<T>.
narrow
(IndexedSeq<? extends T>
An IndexedSeq.
indexedSeq
)

Narrows a widened IndexedSeq<?

public IndexedSeq<T>
orElse(Iterable<? extends T>
An alternative Traversable
other
)

Redeclares io.vavr.collection.Seq.orElse.

Returns this Traversable if it is nonempty, otherwise return the alternative.

public IndexedSeq<T>
orElse(Supplier<? extends Iterable<? extends T>>
An alternative Traversable supplier
supplier
)

Redeclares io.vavr.collection.Seq.orElse.

Returns this Traversable if it is nonempty, otherwise return the result of evaluating supplier.

public IndexedSeq<T>
padTo(int
the target length
length
,
T
the padding element
element
)

Redeclares io.vavr.collection.Seq.padTo.

A copy of this sequence with an element appended until a given target length is reached.

public Tuple2<? extends IndexedSeq<T>, ? extends IndexedSeq<T>>
partition(Predicate<? super T>
A predicate which classifies an element if it is in the first or the second traversable.
predicate
)

Redeclares io.vavr.collection.Seq.partition.

Creates a partition of this Traversable by splitting this elements in two in distinct traversables according to a predicate.

public IndexedSeq<T>
patch(int
the index of the first replaced element
from
,
Iterable<? extends T>
sequence for replacement
that
,
int
the number of elements to drop in the original list
replaced
)

Redeclares io.vavr.collection.Seq.patch.

Produces a new list where a slice of elements in this list is replaced by another sequence.

public IndexedSeq<T>
peek(Consumer<? super T>
The action that will be performed on the element(s).
action
)

Redeclares io.vavr.collection.Seq.peek.

Performs the given action on the first element if this is an eager implementation.

public IndexedSeq<? extends IndexedSeq<T>>
permutations()

Redeclares io.vavr.collection.Seq.permutations.

Computes all unique permutations.

public IndexedSeq<T>
prepend(T
An element
element
)

Redeclares io.vavr.collection.Seq.prepend.

Prepends an element to this.

public IndexedSeq<T>
prependAll(Iterable<? extends T>
An Iterable of elements
elements
)

Redeclares io.vavr.collection.Seq.prependAll.

Prepends all given elements to this.

public IndexedSeq<T>
reject(Predicate<? super T>
A predicate
predicate
)

Redeclares io.vavr.collection.Seq.reject.

Returns a new traversable consisting of all elements which do not satisfy the given predicate.

public IndexedSeq<T>
remove(T
An element to be removed from this Seq.
element
)

Redeclares io.vavr.collection.Seq.remove.

Removes the first occurrence of the given element.

public IndexedSeq<T>
removeAll(T
An element to be removed from this Seq.
element
)

Redeclares io.vavr.collection.Seq.removeAll.

Removes all occurrences of the given element.

public IndexedSeq<T>
removeAll(Iterable<? extends T>
Elements to be removed from this Seq.
elements
)

Redeclares io.vavr.collection.Seq.removeAll, io.vavr.collection.Seq.removeAll.

Removes all occurrences of the given elements.

public IndexedSeq<T>
removeAll(Predicate<? super T>
the predicate used to test elements
predicate
)

Redeclares io.vavr.collection.Seq.removeAll, io.vavr.collection.Seq.removeAll.

Deprecated

Returns a new Seq consisting of all elements which do not satisfy the given predicate.

public IndexedSeq<T>
removeAt(int
position of element to remove
index
)

Redeclares io.vavr.collection.Seq.removeAt.

Removes the element at the specified position in this sequence.

public IndexedSeq<T>
removeFirst(Predicate<T>
an predicate
predicate
)

Redeclares io.vavr.collection.Seq.removeFirst.

Removes the first occurrence that satisfy predicate

public IndexedSeq<T>
removeLast(Predicate<T>
an predicate
predicate
)

Redeclares io.vavr.collection.Seq.removeLast.

Removes the last occurrence that satisfy predicate

public IndexedSeq<T>
replace(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Redeclares io.vavr.collection.Seq.replace.

Replaces the first occurrence (if exists) of the given currentElement with newElement.

public IndexedSeq<T>
replaceAll(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Redeclares io.vavr.collection.Seq.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

public IndexedSeq<T>
retainAll(Iterable<? extends T>
Elements to be kept.
elements
)

Redeclares io.vavr.collection.Seq.retainAll.

Keeps all occurrences of the given elements from this.

public IndexedSeq<T>
reverse()

Redeclares io.vavr.collection.Seq.reverse.

Reverses the order of elements.

public default Iterator<T>
reverseIterator()

Implements io.vavr.collection.Seq.reverseIterator.

An iterator yielding elements in reversed order.

public IndexedSeq<T>
rotateLeft(int
distance of left rotation
n
)

Redeclares io.vavr.collection.Seq.rotateLeft.

Circular rotates the elements by the specified distance to the left direction.

public IndexedSeq<T>
rotateRight(int
distance of right rotation
n
)

Redeclares io.vavr.collection.Seq.rotateRight.

Circular rotates the elements by the specified distance to the right direction.

public IndexedSeq<T>
scan(T
neutral element for the operator op
zero
,
BiFunction<? super T, ? super T, ? extends T>
the associative operator for the scan
operation
)

Redeclares io.vavr.collection.Seq.scan.

Computes a prefix scan of the elements of the collection.

public <U> IndexedSeq<U>
scanLeft(U
the initial value
zero
,
BiFunction<? super U, ? super T, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Redeclares io.vavr.collection.Seq.scanLeft.

Produces a collection containing cumulative results of applying the operator going left to right.

public <U> IndexedSeq<U>
scanRight(U
the initial value
zero
,
BiFunction<? super T, ? super U, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Redeclares io.vavr.collection.Seq.scanRight.

Produces a collection containing cumulative results of applying the operator going right to left.

public default int

Returns:

the index of the search element, if it is contained in the sequence; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the element would be inserted into the sequence. Note that this guarantees that the return value will be >= 0 if and only if the element is found.
search
(T
the element to find
element
)

Implements io.vavr.collection.Seq.search.

Searches this sequence for a specific element using a binary search.

public default int

Returns:

the index of the search element, if it is contained in the sequence; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the element would be inserted into the sequence. Note that this guarantees that the return value will be >= 0 if and only if the element is found.
search
(T
the element to find
element
,
Comparator<? super T>
the comparator by which this sequence is ordered
comparator
)

Implements io.vavr.collection.Seq.search.

Searches this sequence for a specific element using a binary search.

public default int
segmentLength(Predicate<? super T>
the predicate used to test elements.
predicate
,
int
the index where the search starts.
from
)

Implements io.vavr.collection.Seq.segmentLength.

Computes length of longest segment whose elements all satisfy some predicate.

public IndexedSeq<T>
shuffle()

Redeclares io.vavr.collection.Seq.shuffle.

Randomize the order of the elements in the current sequence.

public IndexedSeq<T>
slice(int
the beginning index, inclusive
beginIndex
,
int
the end index, exclusive
endIndex
)

Redeclares io.vavr.collection.Seq.slice.

Returns a Seq that is a slice of this.

public Iterator<? extends IndexedSeq<T>>
slideBy(Function<? super T, ?>
A function which classifies elements into classes
classifier
)

Redeclares io.vavr.collection.Seq.slideBy.

Slides a non-overlapping window of a variable size over this Traversable.

public Iterator<? extends IndexedSeq<T>>
sliding(int
a positive window size
size
)

Redeclares io.vavr.collection.Seq.sliding.

Slides a window of a specific size and step size 1 over this Traversable by calling sliding(int, int).

public Iterator<? extends IndexedSeq<T>>
sliding(int
a positive window size
size
,
int
a positive step size
step
)

Redeclares io.vavr.collection.Seq.sliding.

Slides a window of a specific size and step size over this Traversable.

public <U extends Comparable<? super U>> IndexedSeq<T>
sortBy(Function<? super T, ? extends U>
A mapper
mapper
)

Redeclares io.vavr.collection.Seq.sortBy.

Sorts this elements by comparing the elements in a different domain, using the given mapper.

public <U> IndexedSeq<T>
sortBy(Comparator<? super U>
A comparator
comparator
,
Function<? super T, ? extends U>
A mapper
mapper
)

Redeclares io.vavr.collection.Seq.sortBy.

Sorts this elements by comparing the elements in a different domain, using the given mapper.

public IndexedSeq<T>
sorted()

Redeclares io.vavr.collection.Seq.sorted.

Sorts this elements according to their natural order.

public IndexedSeq<T>
sorted(Comparator<? super T>
A comparator
comparator
)

Redeclares io.vavr.collection.Seq.sorted.

Sorts this elements according to the provided Comparator.

public Tuple2<? extends IndexedSeq<T>, ? extends IndexedSeq<T>>
span(Predicate<? super T>
A predicate.
predicate
)

Redeclares io.vavr.collection.Seq.span.

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.

public default boolean
startsWith(Iterable<? extends T>
the sequence to test
that
,
int
the index where the sequence is searched.
offset
)

Overrides default io.vavr.collection.Seq.startsWith.

Tests whether this list contains the given sequence at a given index.

public IndexedSeq<T>
subSequence(int
the beginning index, inclusive
beginIndex
)

Redeclares io.vavr.collection.Seq.subSequence.

Returns a Seq that is a subsequence of this.

public IndexedSeq<T>
subSequence(int
the beginning index, inclusive
beginIndex
,
int
the end index, exclusive
endIndex
)

Redeclares io.vavr.collection.Seq.subSequence.

Returns a Seq that is a subsequence of this.

public IndexedSeq<T>
tail()

Redeclares io.vavr.collection.Seq.tail.

Drops the first element of a non-empty Traversable.

public Option<? extends IndexedSeq<T>>
tailOption()

Redeclares io.vavr.collection.Seq.tailOption.

Drops the first element of a non-empty Traversable and returns an Option.

public IndexedSeq<T>
take(int
The number of elements to take.
n
)

Redeclares io.vavr.collection.Seq.take.

Takes the first n elements of this or all elements, if this length < n.

public IndexedSeq<T>
takeRight(int
The number of elements to take.
n
)

Redeclares io.vavr.collection.Seq.takeRight.

Takes the last n elements of this or all elements, if this length < n.

public IndexedSeq<T>
takeRightUntil(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Redeclares io.vavr.collection.Seq.takeRightUntil.

Takes elements until the predicate holds for the current element, starting from the end.

public IndexedSeq<T>
takeRightWhile(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Redeclares io.vavr.collection.Seq.takeRightWhile.

Takes elements while the predicate holds for the current element, starting from the end.

public IndexedSeq<T>
takeUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Redeclares io.vavr.collection.Seq.takeUntil.

Takes elements until the predicate holds for the current element.

public IndexedSeq<T>
takeWhile(Predicate<? super T>
A condition tested subsequently for the contained elements.
predicate
)

Redeclares io.vavr.collection.Seq.takeWhile.

Takes elements while the predicate holds for the current element.

public <T1, T2> Tuple2<? extends IndexedSeq<T1>, ? extends IndexedSeq<T2>>
unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>>
a function which converts elements of this to pairs
unzipper
)

Redeclares io.vavr.collection.Seq.unzip.

Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct sets.

public <T1, T2, T3> Tuple3<? extends IndexedSeq<T1>, ? extends IndexedSeq<T2>, ? extends IndexedSeq<T3>>
unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>>
a function which converts elements of this to pairs
unzipper
)

Redeclares io.vavr.collection.Seq.unzip3.

Unzips this elements by mapping this elements to triples which are subsequently split into three distinct sets.

public IndexedSeq<T>
update(int
an index
index
,
T
an element
element
)

Redeclares io.vavr.collection.Seq.update.

Updates the given element at the specified index.

public IndexedSeq<T>
update(int
an index
index
,
Function<? super T, ? extends T>
a function transforming the previous value
updater
)

Redeclares io.vavr.collection.Seq.update, io.vavr.collection.Seq.update.

Updates the given element at the specified index using the specified function.

public <U> IndexedSeq<Tuple2<T, U>>
zip(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
)

Redeclares io.vavr.collection.Seq.zip.

Returns a traversable formed from this traversable and another Iterable collection by combining corresponding elements in pairs.

public <U> IndexedSeq<Tuple2<T, U>>
zipAll(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
,
T
The element to be used to fill up the result if this traversable is shorter than that.
thisElem
,
U
The element to be used to fill up the result if that is shorter than this traversable.
thatElem
)

Redeclares io.vavr.collection.Seq.zipAll.

Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in pairs.

public <U, R> IndexedSeq<R>
zipWith(Iterable<? extends U>
The Iterable providing the second parameter of the mapper.
that
,
BiFunction<? super T, ? super U, ? extends R>
a mapper.
mapper
)

Redeclares io.vavr.collection.Seq.zipWith.

Returns a traversable formed from this traversable and another Iterable collection by mapping elements.

public IndexedSeq<Tuple2<T, Integer>>
zipWithIndex()

Redeclares io.vavr.collection.Seq.zipWithIndex.

Zips this traversable with its indices.

public <U> IndexedSeq<U>
zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U>
a mapper.
mapper
)

Redeclares io.vavr.collection.Seq.zipWithIndex.

Zips this traversable with its indices by applying mapper provided.

Inherited from io.vavr.collection.Seq:
applyasJavaasJavaMutablecontainsSlicecrossProductcrossProductfoldRightgetindexOfindexOfindexOfOptionindexOfOptionindexOfSliceindexOfSliceOptionindexOfSliceOptionindexWhereindexWhereOptionindexWhereOptionisSequentialiteratorlastIndexOflastIndexOflastIndexOfOptionlastIndexOfOptionlastIndexOfSlicelastIndexOfSliceOptionlastIndexOfSliceOptionlastIndexWherelastIndexWhereOptionlastIndexWhereOptionleftPadToliftnarrowprefixLengthsplitAtsplitAtsplitAtInclusivestartsWithwithDefaultwithDefaultValue