Top Description Fields Methods
io.vavr.collection

public Interface LinearSeq<T>

Additional top-level class in compilation unit: LinearSeqModule.

extends Seq<T>
Known Direct Subinterfaces
io.vavr.collection.List, io.vavr.collection.Stream
Known Direct Implementers
io.vavr.collection.Queue
Type Parameters
<T>
component type
Imports
io.vavr.PartialFunction, .Tuple, .Tuple2, io.vavr.control.Option, java.util.Comparator, .Objects, java.util.function.*

Interface for immutable, linear sequences.

Efficient head(), tail(), and isEmpty() methods are characteristic for linear sequences.

Author
Daniel Dietrich

Field Summary

Modifier and TypeField and Description
public static final long

Method Summary

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

Redeclares io.vavr.collection.Seq.append.

Appends an element to this.

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

Redeclares io.vavr.collection.Seq.appendAll.

Appends all given elements to this.

public LinearSeq<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 LinearSeq<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> LinearSeq<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 LinearSeq<? extends LinearSeq<T>>
combinations()

Redeclares io.vavr.collection.Seq.combinations.

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

public LinearSeq<? extends LinearSeq<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 LinearSeq<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 LinearSeq<T>
distinct()

Redeclares io.vavr.collection.Seq.distinct.

Returns a new version of this which contains no duplicates.

public LinearSeq<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> LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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> LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<T>
init()

Redeclares io.vavr.collection.Seq.init.

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

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

Redeclares io.vavr.collection.Seq.initOption.

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

public LinearSeq<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 LinearSeq<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 LinearSeq<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 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> LinearSeq<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 LinearSeq.
T
>
LinearSeq<T>

Returns:

the given linearSeq instance as narrowed type LinearSeq<T>.
narrow
(LinearSeq<? extends T>
A LinearSeq.
linearSeq
)

Narrows a widened LinearSeq<?

public LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<T>, ? extends LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<? extends LinearSeq<T>>
permutations()

Redeclares io.vavr.collection.Seq.permutations.

Computes all unique permutations.

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

Redeclares io.vavr.collection.Seq.prepend.

Prepends an element to this.

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

Redeclares io.vavr.collection.Seq.prependAll.

Prepends all given elements to this.

public LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<T>
removeFirst(Predicate<T>
an predicate
predicate
)

Redeclares io.vavr.collection.Seq.removeFirst.

Removes the first occurrence that satisfy predicate

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

Redeclares io.vavr.collection.Seq.removeLast.

Removes the last occurrence that satisfy predicate

public LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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> LinearSeq<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> LinearSeq<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 linear 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 linear 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 LinearSeq<T>
shuffle()

Redeclares io.vavr.collection.Seq.shuffle.

Randomize the order of the elements in the current sequence.

public LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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>> LinearSeq<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> LinearSeq<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 LinearSeq<T>
sorted()

Redeclares io.vavr.collection.Seq.sorted.

Sorts this elements according to their natural order.

public LinearSeq<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 LinearSeq<T>, ? extends LinearSeq<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 LinearSeq<T>
subSequence(int
the beginning index, inclusive
beginIndex
)

Redeclares io.vavr.collection.Seq.subSequence.

Returns a Seq that is a subsequence of this.

public LinearSeq<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 LinearSeq<T>
tail()

Redeclares io.vavr.collection.Seq.tail.

Drops the first element of a non-empty Traversable.

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

Redeclares io.vavr.collection.Seq.tailOption.

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

public LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<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 LinearSeq<T1>, ? extends LinearSeq<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 LinearSeq<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 LinearSeq<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> LinearSeq<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> LinearSeq<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> LinearSeq<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 LinearSeq<Tuple2<T, Integer>>
zipWithIndex()

Redeclares io.vavr.collection.Seq.zipWithIndex.

Zips this traversable with its indices.

public <U> LinearSeq<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:
applyasJavaasJavaMutablecontainsSlicecrossProductcrossProductendsWithfoldRightgetindexOfindexOfindexOfOptionindexOfOptionindexOfSliceindexOfSliceOptionindexOfSliceOptionindexWhereindexWhereOptionindexWhereOptionisSequentialiteratorlastIndexOflastIndexOflastIndexOfOptionlastIndexOfOptionlastIndexOfSlicelastIndexOfSliceOptionlastIndexOfSliceOptionlastIndexWherelastIndexWhereOptionlastIndexWhereOptionleftPadToliftnarrowprefixLengthsplitAtsplitAtsplitAtInclusivestartsWithstartsWithunzip3withDefaultwithDefaultValue