Scala Library
|
|
scala/collection/LinearSeqLike.scala
]
trait
LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]]
extends
SeqLike[A, Repr]Linear[A]
represents linear sequences of elements.
For such sequences `isEmpty`, `head` and `tail` are guaranteed to be
efficient constant time (or near so) operations.
It does not add any methods to Seq
but overrides
several methods with optimized implementations.Method Summary | |
def
|
apply
(n : Int) : A
Returns the
n -th element of this linear sequence. The first element
(head of the linear sequence) is at position 0. |
override def
|
count
(p : (A) => Boolean) : Int
Count the number of elements in the iterable which satisfy a predicate.
|
override def
|
drop
(n : Int) : Repr
Returns this traversable without its
n first elements
If this traversable has less than n elements, the empty
traversable is returned. |
override def
|
dropRight
(n : Int) : Repr
Returns the rightmost
n elements from this iterable. |
override def
|
exists
(p : (A) => Boolean) : Boolean
Tests the existence in this list of an element that satisfies the
predicate
p . |
override def
|
find
(p : (A) => Boolean) : Option[A]
Find and return the first element of the list satisfying a
predicate, if any.
|
override def
|
foldLeft
[B](z : B)(f : (B, A) => B) : B
Combines the elements of this list together using the binary
function
f , from left to right, and starting with
the value z . |
override def
|
foldRight
[B](z : B)(f : (A, B) => B) : B
Combines the elements of this list together using the binary
function
f , from right to left, and starting with
the value z . |
override def
|
forall
(p : (A) => Boolean) : Boolean
Tests if the predicate
p is satisfied by all elements
in this list. |
override def
|
foreach
[B](f : (A) => B) : Unit
Apply the given function
f to each element of this linear sequence
(while respecting the order of the elements). |
abstract def
|
head
: A
Abstract method to be implemented in a subclass
|
override def
|
indexWhere
(p : (A) => Boolean, from : Int) : Int
Returns index of the first element starting from a start index
satisying a predicate, or -1, if none exists.
|
override def
|
isDefinedAt
(x : Int) : Boolean
Is this partial function defined for the index
x ? |
abstract def
|
isEmpty
: Boolean
Abstract method to be implemented in a subclass
|
override def
|
iterator
: Iterator[A]
Returns the elements in the sequence as an iterator
|
override def
|
last
: A
The last element of this linear sequence.
|
override def
|
lastIndexWhere
(p : (A) => Boolean, end : Int) : Int
Returns index of the last element satisying a predicate, or -1, if none exists.
|
def
|
length
: Int
Returns the number of elements in the linear sequence.
|
override def
|
lengthCompare
(len : Int) : Int
Result of comparing
length with operand len .
returns x where
x < 0 iff this.length < len
x == 0 iff this.length == len
x > 0 iff this.length > len . |
override def
|
reduceLeft
[B >: A](f : (B, A) => B) : B
Combines the elements of this list together using the binary
operator
op , from left to right |
override def
|
reduceRight
[B >: A](op : (A, B) => B) : B
Combines the elements of this iterable object together using the binary
operator
op , from right to left |
override def
|
sameElements
[B >: A](that : Iterable[B]) : Boolean
Returns
true iff the other linear sequence contains the
same elements as this one. |
override def
|
segmentLength
(p : (A) => Boolean, from : Int) : Int
Returns length of longest segment starting from a start index `from`
such that every element of the segment satisfies predicate `p`.
|
override def
|
slice
(from : Int, until : Int) : Repr
A sub-traversable starting at index `from`
and extending up to (but not including) index `until`.
|
override def
|
span
(p : (A) => Boolean) : (Repr, Repr)
Returns a pair consisting of the longest prefix of the linear sequence whose
elements all satisfy the given predicate, and the rest of the linear sequence.
|
abstract def
|
tail
: Repr
Abstract method to be implemented in a subclass
|
override def
|
take
(n : Int) : Repr
Return an iterable consisting only of the first
n
elements of this iterable, or else the whole iterable, if it has less
than n elements. |
override def
|
takeWhile
(p : (A) => Boolean) : Repr
Returns the longest prefix of this traversable whose elements satisfy
the predicate
p . |
protected[this] override def
|
thisCollection : LinearSeq[A] |
protected[this] override def
|
toCollection (repr : Repr) : LinearSeq[A] |
Methods inherited from SeqLike | |
size, prefixLength, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, reverse, reverseMap, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, view, view, hashCode, equals, toString, findLastIndexOf, equalsWith, containsSlice, projection |
Methods inherited from IterableLike | |
elements, toIterable, takeRight, copyToArray, zip, zipAll, zipWithIndex, toStream, canEqual, first, firstOption |
Methods inherited from TraversableLike | |
newBuilder (abstract), repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, /:, :\, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, lastOption, init, dropWhile, splitAt, copyToBuffer, copyToArray, toArray, toList, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix, withFilter |
Methods inherited from AnyRef | |
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Method Details |
abstract
def
isEmpty : Boolean
abstract
def
head : A
abstract
def
tail : Repr
def
length : Int
n
-th element of this linear sequence. The first element
(head of the linear sequence) is at position 0.n -
index of the element to returnn
in this linear sequence.f
to each element of this linear sequence
(while respecting the order of the elements).f -
the treatment to apply to each element.p
is satisfied by all elements
in this list.p -
the test predicate.true
iff all elements of this list satisfy the predicate p
.p
.p -
the test predicate.true
iff there exists an element in this list that satisfies the predicate p
.p -
the predicate for which to countp
.p -
the predicatep
, or None
if none exists.f
, from left to right, and starting with
the value z
.f(... (f(f(z, a0), a1) ...), an)
if the list is
[a0, a1, ..., an]
.f
, from right to left, and starting with
the value z
.f(a0, f(a1, f(..., f(an, z)...)))
if the list is [a0, a1, ..., an]
.op
, from left to rightop -
The operator to applyop(... op(a0,a1), ..., an)
if the list has elements
a0, a1, ..., an
.op
, from right to leftop -
The operator to applya0 op (... op (an-1 op an)...)
if the iterable object has elements a0, a1, ...,
an
.override
def
last : A
n
elements of this iterable, or else the whole iterable, if it has less
than n
elements.n -
the number of elements to taken
first elements
If this traversable has less than n
elements, the empty
traversable is returned.n -
the number of elements to dropn
elements from this iterable.n -
the number of elements to takefrom -
The index of the first element of the returned subsequenceuntil -
The index of the element following the returned subsequencep
.p -
the test predicate.p -
the test predicatetrue
iff the other linear sequence contains the
same elements as this one.that -
the other linear sequencelength
with operand len
.
returns x
where
x < 0
iff this.length < len
x == 0
iff this.length == len
x > 0
iff this.length > len
.x
?p -
the predicatefrom -
the start indexp -
the predicatefrom -
the start indexp -
the predicatep
, or -1 if such an element does not exist
Scala Library
|
|