Scala Library
|
|
scala/Seq.scala
]
trait
Seq[+A]
extends
PartialFunction[Int, A] with
Collection[A]Seq[A]
represents finite sequences of elements
of type A
.Method Summary | |
override def
|
++
[B >: A](that : Iterable[B]) : Seq[B]
Appends two iterable objects.
|
override def
|
concat
[B >: A](that : Iterable[B]) : Seq[B]
Appends two iterable objects.
|
def
|
contains
(elem : Any) : Boolean
Tests if the given value
elem is a member of this
sequence. |
def
|
containsSlice
[B](that : Seq[B]) : Boolean
Is
that a slice in this? |
override def
|
drop
(n : Int) : Seq[A]
Returns this sequence without its
n first elements
If this sequence has less than n elements, the empty
sequence is returned. (non-strict) |
override def
|
dropWhile
(p : (A) => Boolean) : Seq[A]
Returns the longest suffix of this sequence whose first element
does not satisfy the predicate
p . |
def
|
endsWith [B](that : Seq[B]) : Boolean |
def
|
equalsWith [B](that : Seq[B])(f : (A, B) => Boolean) : Boolean |
override def
|
filter
(p : (A) => Boolean) : Seq[A]
Returns all the elements of this sequence that satisfy the
predicate
p . The order of the elements is preserved. |
override def
|
findIndexOf
(p : (A) => Boolean) : Int
Returns index of the first element satisying a predicate, or -1.
|
def
|
first
: A
Returns the first element of this list.
|
def
|
firstOption
: Option[A]
Returns as an option the first element of this list or
None if list is empty. |
override def
|
flatMap
[B](f : (A) => Iterable[B]) : Seq[B]
Applies the given function
f to each element of
this sequence, then concatenates the results. |
def
|
headOption : Option[A] |
override def
|
indexOf
[B >: A](elem : B) : Int
Returns the index of the first occurence of the specified
object in this iterable object.
|
def
|
indexOf
[B >: A](that : Seq[B]) : Int
Searches for the argument sequence in the receiver object, returning
the smallest index where a match occurs.
If the receiver object,
this , is an infinite sequence
this method will not terminate if there is no match. Similarly, if
the both the receiver object and the argument, that are
infinite sequences this method will not terminate.
Because both the receiver object and the argument can both potentially
be an infinite sequences, we do not attempt to use an optimized
searching algorithm. Therefore, the running time will be proportional
to the length of the receiver object and the argument. Subclasses and
traits can potentially provide an optimized implementation. |
def
|
isDefinedAt
(x : Int) : Boolean
Is this partial function defined for the index
x ? |
override def
|
isEmpty
: Boolean
Returns true if length == 0
|
def
|
last
: A
Returns the last element of this list.
|
def
|
lastIndexOf
[B >: A](elem : B) : Int
Returns the index of the last occurence of the specified element
in this sequence, or -1 if the sequence does not contain this element.
|
def
|
lastOption
: Option[A]
Returns as an option the last element of this list or
None if list is empty. |
abstract def
|
length
: Int
Returns the length of the sequence.
|
def
|
lengthCompare
(l : Int) : Int
Result of comparing
length with operand l .
returns x where
x < 0 iff this.length < l
x == 0 iff this.length == l
x > 0 iff this.length > that .
This method is used by matching streams against right-ignoring (...,_*) patterns.
Lazy sequences should override this method if length forces evaluation of the stream. |
override def
|
map
[B](f : (A) => B) : Seq[B]
Returns the sequence resulting from applying the given function
f to each element of this sequence. |
override def
|
projection
: Projection[A]
returns a projection that can be used to call non-strict
filter ,
map , and flatMap methods that build projections
of the collection. |
def
|
reverse
: Seq[A]
A sequence consisting of all elements of this sequence in reverse order.
|
def
|
size
: Int
should always be
length |
def
|
slice
(from : Int, until : Int) : Seq[A]
A sub-sequence starting at index
from
and ending (non-inclusive) at index until (non-strict) |
def
|
slice
(from : Int) : Seq[A]
A sub-sequence starting at index
from
and extending up to the length of the current sequence (non-strict) |
def
|
startsWith
[B](that : Seq[B], offset : Int) : Boolean
Checks whether the argument sequence is contained at the
specified index within the receiver object.
If the both the receiver object,
this and
the argument, that are infinite sequences
this method may not terminate. |
def
|
startsWith
[B](that : Seq[B]) : Boolean
Check whether the receiver object starts with the argument sequence.
|
def
|
subseq
(from : Int, end : Int) : Seq[A]
Returns a subsequence starting from index
from
consisting of len elements. |
override def
|
take
(n : Int) : Seq[A]
Returns a sequence consisting only over the first
n
elements of this sequence, or else the whole sequence, if it has less
than n elements. (non-strict) |
override def
|
takeWhile
(p : (A) => Boolean) : Seq[A]
Returns the longest prefix of this sequence whose elements satisfy
the predicate
p . |
override def
|
toArray
[B >: A] : Array[B]
Converts this sequence to a fresh Array with
length elements. |
override def
|
toSeq
: Seq[A]
Overridden for efficiency.
|
Methods inherited from Collection | |
toString, stringPrefix |
Methods inherited from Iterable | |
elements (abstract), partition, foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize |
Methods inherited from PartialFunction | |
orElse, andThen |
Methods inherited from Function1 | |
apply (abstract), compose |
Methods inherited from AnyRef | |
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Method Details |
abstract
def
length : Int
length
with operand l
.
returns x
where
x < 0
iff this.length < l
x == 0
iff this.length == l
x > 0
iff this.length > that
.
This method is used by matching streams against right-ignoring (...,_*) patterns.
Lazy sequences should override this method if length forces evaluation of the stream.
def
size : Int
length
override
def
isEmpty : Boolean
++
instead
def
last : A
None
if list is empty.
def
first : A
None
if list is empty.
def
headOption : Option[A]
x
?x -
..true
, iff x
is a legal sequence index.elem -
element to search for.p -
the predicatep
, or -1 if such an element does not existelem -
element to search for.f
to each element of this sequence.f -
function to apply to each element.f(a0), ..., f(an)
if this sequence is a0, ..., an
.f
to each element of
this sequence, then concatenates the results.f -
the function to apply on each element.f(a0) ::: ... ::: f(an)
if this sequence is a0, ..., an
.p
. The order of the elements is preserved.p -
the predicate used to filter the list.p
.n
elements of this sequence, or else the whole sequence, if it has less
than n
elements. (non-strict)n -
the number of elements to taken
first elements
If this sequence has less than n
elements, the empty
sequence is returned. (non-strict)n -
the number of elements to dropfrom
and ending (non-inclusive) at index until
(non-strict)from -
The index of the first element of the sliceuntil -
The index of the element following the sliceIndexOutOfBoundsException -
if from < 0
or length < from + len
def
slice(from : Int) : Seq[A]
from
and extending up to the length of the current sequence (non-strict)from -
The index of the first element of the sliceIndexOutOfBoundsException -
if from < 0
drop(n: Int): Seq[A]
instead.p
.p -
the test predicate.p
.p
.p -
the test predicate.p
.elem
is a member of this
sequence.elem -
element whose membership has to be tested.true
iff there is an element of this sequence which is equal (w.r.t. ==
) to elem
.
def
subseq(from : Int, end : Int) : Seq[A]
from
consisting of len
elements.slice
insteadlength
elements.override
def
projection : Projection[A]
filter
,
map
, and flatMap
methods that build projections
of the collection.this
and
the argument, that
are infinite sequences
this method may not terminate.that
is contained in this
, at the specified index, otherwise falsethat
is a prefix of this
, otherwise falsethis
, is an infinite sequence
this method will not terminate if there is no match. Similarly, if
the both the receiver object and the argument, that
are
infinite sequences this method will not terminate.
Because both the receiver object and the argument can both potentially
be an infinite sequences, we do not attempt to use an optimized
searching algorithm. Therefore, the running time will be proportional
to the length of the receiver object and the argument. Subclasses and
traits can potentially provide an optimized implementation.that
not contained in this
, otherwise the smallest index where that
is found.that
a slice in this?
Scala Library
|
|