GenericTraversableTemplate
A template class for companion objects of regular
collection classes
that represent an unconstrained higher-kinded type.
A template class for companion objects of regular
collection classes
that represent an unconstrained higher-kinded type.
- Type Params
- A
The type of the collection elements.
- CC
The type constructor representing the collection class.
Value members
Abstract methods
The factory companion object that builds instances of class $Coll.
(or its Iterable
superclass where class $Coll is not a Seq
.)
The factory companion object that builds instances of class $Coll.
(or its Iterable
superclass where class $Coll is not a Seq
.)
Applies a function f
to all elements of this collection.
Applies a function f
to all elements of this collection.
- Type Params
- U
the type parameter describing the result of function
f
. This result will always be ignored. TypicallyU
isUnit
, but this is not necessary.
- Value Params
- f
the function that is applied for its side-effect to every element. The result of function
f
is discarded.
Selects the first element of this collection.
Selects the first element of this collection.
- Returns
the first element of this collection.
- Throws
- NoSuchElementException
if the collection is empty.
Tests whether this collection is empty.
Tests whether this collection is empty.
- Returns
true
if the collection contain no elements,false
otherwise.
Concrete methods
Converts this collection of traversable collections into a collection formed by the elements of these traversable collections.
Converts this collection of traversable collections into a collection formed by the elements of these traversable collections.
- Type Params
- B
the type of the elements of each traversable collection.
- Value Params
- asTraversable
an implicit conversion which asserts that the element type of this collection is a
GenTraversable
.
- Returns
a new collection resulting from concatenating all element collections.
The generic builder that builds instances of $Coll at arbitrary element types.
The generic builder that builds instances of $Coll at arbitrary element types.
Transposes this collection of traversable collections into a collection of collections.
Transposes this collection of traversable collections into a collection of collections.
The resulting collection's type will be guided by the static type of collection. For example:
val xs = List(
Set(1, 2, 3),
Set(4, 5, 6)).transpose
// xs == List(
// List(1, 4),
// List(2, 5),
// List(3, 6))
val ys = Vector(
List(1, 2, 3),
List(4, 5, 6)).transpose
// ys == Vector(
// Vector(1, 4),
// Vector(2, 5),
// Vector(3, 6))
- Type Params
- B
the type of the elements of each traversable collection.
- Value Params
- asTraversable
an implicit conversion which asserts that the element type of this collection is a
Traversable
.
- Returns
a two-dimensional collection of collections which has as ''n''th row the ''n''th column of this collection.
- Throws
- IllegalArgumentException
if all collections in this collection are not of the same size.
Converts this collection of pairs into two collections of the first and second half of each pair.
Converts this collection of pairs into two collections of the first and second half of each pair.
val xs = $Coll(
(1, "one"),
(2, "two"),
(3, "three")).unzip
// xs == ($Coll(1, 2, 3),
// $Coll(one, two, three))
- Type Params
- A1
the type of the first half of the element pairs
- A2
the type of the second half of the element pairs
- Value Params
- asPair
an implicit conversion which asserts that the element type of this collection is a pair.
- Returns
a pair of collections, containing the first, respectively second half of each element pair of this collection.
Converts this collection of triples into three collections of the first, second, and third element of each triple.
Converts this collection of triples into three collections of the first, second, and third element of each triple.
val xs = $Coll(
(1, "one", '1'),
(2, "two", '2'),
(3, "three", '3')).unzip3
// xs == ($Coll(1, 2, 3),
// $Coll(one, two, three),
// $Coll(1, 2, 3))
- Type Params
- A1
the type of the first member of the element triples
- A2
the type of the second member of the element triples
- A3
the type of the third member of the element triples
- Value Params
- asTriple
an implicit conversion which asserts that the element type of this collection is a triple.
- Returns
a triple of collections, containing the first, second, respectively third member of each element triple of this collection.