trait Coll[A] extends AnyRef
Indexed (zero-based) collection of elements of type A
.
NOTE: declaring it abstract class
makes some performance benefits, but doesn't work
well with specialization.
- Alphabetic
- By Inheritance
- Coll
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def append(other: Coll[A]): Coll[A]
Puts the elements of other collection after the elements of this collection (concatenation of 2 collections)
- abstract def apply(i: Int): A
The element at given index.
The element at given index. Indices start at
0
;xs.apply(0)
is the first element of collectionxs
. Note the indexing syntaxxs(i)
is a shorthand forxs.apply(i)
.- i
the index
- returns
the element at the given index
- Exceptions thrown
ArrayIndexOutOfBoundsException
ifi < 0
orlength <= i
- abstract def builder: CollBuilder
- abstract def exists(p: (A) => Boolean): Boolean
Tests whether a predicate holds for at least one element of this collection.
Tests whether a predicate holds for at least one element of this collection.
- p
the predicate used to test elements.
- returns
true
if the given predicatep
is satisfied by at least one element of this collection, otherwisefalse
- abstract def filter(p: (A) => Boolean): Coll[A]
Selects all elements of this collection which satisfy a predicate.
Selects all elements of this collection which satisfy a predicate.
- p
the predicate used to test elements.
- returns
a new collection consisting of all elements of this collection that satisfy the given predicate
p
. The order of the elements is preserved.
- Since
2.0
- abstract def flatMap[B](f: (A) => Coll[B])(implicit arg0: RType[B]): Coll[B]
Builds a new collection by applying a function to all elements of this collection and using the elements of the resulting collections.
Builds a new collection by applying a function to all elements of this collection and using the elements of the resulting collections.
Function
f
is constrained to be of the formx => x.someProperty
, otherwise it is illegal.- B
the element type of the returned collection.
- f
the function to apply to each element.
- returns
a new collection of type
Coll[B]
resulting from applying the given collection-valued functionf
to each element of this collection and concatenating the results.
- Since
2.0
- abstract def foldLeft[B](zero: B, op: ((B, A)) => B): B
Applies a binary operator to a start value and all elements of this collection, going left to right.
Applies a binary operator to a start value and all elements of this collection, going left to right.
- B
the result type of the binary operator.
- zero
the start value.
- op
the binary operator.
- returns
the result of inserting
op
between consecutive elements of this collection, going left to right with the start valuez
on the left:op(...op(z, x_1), x_2, ..., x_n)
where
x_1, ..., x_n
are the elements of this collection. Returnsz
if this collection is empty.
- abstract def forall(p: (A) => Boolean): Boolean
Tests whether a predicate holds for all elements of this collection.
Tests whether a predicate holds for all elements of this collection.
- p
the predicate used to test elements.
- returns
true
if this collection is empty or the given predicatep
holds for all elements of this collection, otherwisefalse
.
- abstract def getOrElse(index: Int, default: A): A
The element of the collection or default value.
The element of the collection or default value. If an index is out of bounds (
i < 0 || i >= length
) thendefault
value is returned.- returns
the element at the given index or default value if index is out or bounds
- Since
2.0
- abstract def indexWhere(p: (A) => Boolean, from: Int): Int
Finds index of the first element satisfying some predicate after or at some start index.
Finds index of the first element satisfying some predicate after or at some start index.
- p
the predicate used to test elements.
- from
the start index
- returns
the index
>= from
of the first element of this collection that satisfies the predicatep
, or-1
, if none exists.
- Since
2.0
- abstract def indices: Coll[Int]
Produces the range of all indices of this collection as a new collection containing [0 ..
Produces the range of all indices of this collection as a new collection containing [0 .. length-1] values.
- Since
2.0
- abstract def isDefinedAt(idx: Int): Boolean
Tests whether this collection contains given index.
Tests whether this collection contains given index.
The implementations of methods
apply
andisDefinedAt
turn aColl[A]
into aPartialFunction[Int, A]
.- idx
the index to test
- returns
true
if this collection contains an element at positionidx
,false
otherwise.
- abstract def isEmpty: Boolean
Tests whether the collection is empty.
Tests whether the collection is empty.
- returns
true
if the collection contains no elements,false
otherwise.
- abstract def lastIndexWhere(p: (A) => Boolean, end: Int): Int
Finds index of last element satisfying some predicate before or at given end index.
Finds index of last element satisfying some predicate before or at given end index.
- p
the predicate used to test elements.
- returns
the index
<= end
of the last element of this collection that satisfies the predicatep
, or-1
, if none exists.
- Since
2.0
- abstract def length: Int
The length of the collection.
- abstract def map[B](f: (A) => B)(implicit arg0: RType[B]): Coll[B]
Builds a new collection by applying a function to all elements of this collection.
Builds a new collection by applying a function to all elements of this collection.
- B
the element type of the returned collection.
- f
the function to apply to each element.
- returns
a new collection of type
Coll[B]
resulting from applying the given functionf
to each element of this collection and collecting the results.
- abstract def nonEmpty: Boolean
Tests whether the collection is not empty.
Tests whether the collection is not empty.
- returns
true
if the collection contains at least one element,false
otherwise.
- abstract def patch(from: Int, patch: Coll[A], replaced: Int): Coll[A]
Produces a new collection where a slice of elements in this collection is replaced by another sequence.
Produces a new collection where a slice of elements in this collection is replaced by another sequence.
- from
the index of the first replaced element
- patch
the replacement sequence
- replaced
the number of elements to drop in the original collection
- returns
a new collection consisting of all elements of this collection except that
replaced
elements starting fromfrom
are replaced bypatch
.
- Since
2.0
- abstract def reverse: Coll[A]
Returns new collection with elements in reversed order.
Returns new collection with elements in reversed order.
- returns
A new collection with all elements of this collection in reversed order.
- abstract def segmentLength(p: (A) => Boolean, from: Int): Int
Computes length of longest segment whose elements all satisfy some predicate.
Computes length of longest segment whose elements all satisfy some predicate.
- p
the predicate used to test elements.
- from
the index where the search starts.
- returns
the length of the longest segment of this collection starting from index
from
such that every element of the segment satisfies the predicatep
.
- Since
2.0
- abstract def slice(from: Int, until: Int): Coll[A]
Selects an interval of elements.
Selects an interval of elements. The returned collection is made up of all elements
x
which satisfy the invariant:from <= indexOf(x) < until
- from
the lowest index to include from this collection.
- until
the lowest index to EXCLUDE from this collection.
- implicit abstract def tItem: RType[A]
- abstract def take(n: Int): Coll[A]
Selects first n elements.
Selects first n elements.
- n
the number of elements to take from this collection.
- returns
a collection consisting only of the first
n
elements of this collection, or else the whole collection, if it has less thann
elements. Ifn
is negative, returns an empty collection.
- abstract def toArray: Array[A]
- abstract def unionSet(that: Coll[A]): Coll[A]
Produces a new collection which contains all distinct elements of this collection and also all elements of a given collection that are not in this collection.
Produces a new collection which contains all distinct elements of this collection and also all elements of a given collection that are not in this collection. This is order preserving operation considering only first occurrences of each distinct elements. Any collection
xs
can be transformed to a sequence with distinct elements by using xs.unionSet(Col()).NOTE: Use append if you don't need set semantics.
- that
the collection to add.
- Since
2.0
- abstract def updateMany(indexes: Coll[Int], values: Coll[A]): Coll[A]
Returns a copy of this collection where elements at
indexes
are replaced withvalues
.Returns a copy of this collection where elements at
indexes
are replaced withvalues
.- Since
2.0
- abstract def updated(index: Int, elem: A): Coll[A]
A copy of this collection with one single replaced element.
A copy of this collection with one single replaced element.
- index
the position of the replacement
- elem
the replacing element
- returns
a new collection which is a copy of this collection with the element at position
index
replaced byelem
.
- Since
2.0
- Exceptions thrown
IndexOutOfBoundsException
ifindex
does not satisfy0 <= index < length
.
- abstract def zip[B](ys: Coll[B]): Coll[(A, B)]
For this collection (x0, ..., xN) and other collection (y0, ..., yM) produces a collection ((x0, y0), ..., (xK, yK)) where K = min(N, M)
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def diff(that: Coll[A]): Coll[A]
Computes the multiset difference between this collection and another sequence.
Computes the multiset difference between this collection and another sequence.
- that
the sequence of elements to remove
- returns
a new collection which contains all elements of this collection except some of occurrences of elements that also appear in
that
. If an element valuex
appears n times inthat
, then the first n occurrences ofx
will not form part of the result, but any following occurrences will.
- Since
2.0
- def distinct: Coll[A]
Builds a new collection from this collection without any duplicate elements.
Builds a new collection from this collection without any duplicate elements.
- returns
A new collection which contains the first occurrence of every element of this collection.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def find(p: (A) => Boolean): Option[A]
Finds the first element of the collection satisfying a predicate, if any.
Finds the first element of the collection satisfying a predicate, if any.
- p
the predicate used to test elements.
- returns
an option value containing the first element in the collection that satisfies
p
, orNone
if none exists.
- Since
2.0
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def indexOf(elem: A, from: Int): Int
Finds index of first occurrence of some value in this collection after or at some start index.
Finds index of first occurrence of some value in this collection after or at some start index.
- elem
the element value to search for.
- from
the start index
- returns
the index
>= from
of the first element of this collection that is equal (as determined by==
) toelem
, or-1
, if none exists.
- Since
2.0
- def intersect(that: Coll[A]): Coll[A]
Computes the multiset intersection between this collection and another sequence.
Computes the multiset intersection between this collection and another sequence.
- that
the sequence of elements to intersect with.
- returns
a new collection which contains all elements of this collection which also appear in
that
. If an element valuex
appears n times inthat
, then the first n occurrences ofx
will be retained in the result, but any following occurrences will be omitted.
- Since
2.0
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def isValidIndex(i: Int): Boolean
Returns true if the index in the valid range.
Returns true if the index in the valid range.
- i
index of an element of this collection
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def size: Int
The size of the collection in elements.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- Coll → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()