A NonEmptyChunk is a Chunk that is guaranteed to contain at least one element. As a result, operations which would not be safe when performed on Chunk, such as head or reduce, are safe when performed on NonEmptyChunk. Operations on NonEmptyChunk which could potentially return an empty chunk will return a Chunk instead.
Attributes
- Companion
- object
- Source
- Chunk.scala
- Graph
-
- Supertypes
- Self type
Members list
Value members
Abstract methods
Provides an iterator to traverse through the chunk's elements sequentially.
Provides an iterator to traverse through the chunk's elements sequentially.
Attributes
- Source
- Chunk.scala
Concrete methods
Returns the bitwise AND of this chunk and the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Appends the specified Chunk to the end of this NonEmptyChunk.
A symbolic alias for prepended.
A symbolic alias for appended.
Returns the bitwise XOR of this chunk and the specified chunk.
Appends a single element to the end of this NonEmptyChunk.
Creates a base64 encoded string based on the chunk's data.
Converts this NonEmptyChunk of bytes to a NonEmptyChunk of bits.
Converts a chunk of bytes to a chunk of bits.
Converts a chunk of ints to a chunk of bits.
Converts this NonEmptyChunk of ints to a NonEmptyChunk of bits.
Converts a chunk of longs to a chunk of bits.
Converts this NonEmptyChunk of longs to a NonEmptyChunk of bits.
Creates a new String based on this chunk's data.
Creates a new String based on this chunk of bytes and using the given charset.
Creates a new String based on this chunk of bytes and using the given charset.
Attributes
- Source
- Chunk.scala
Get the element at the specified index.
Get the element at the specified index.
Get the element at the specified index.
Applies a partial function to all elements of the chunk for which the function is defined, producing a new chunk containing the results.
Applies a partial function to all elements of the chunk for which the function is defined, producing a new chunk containing the results.
Attributes
- Source
- Chunk.scala
Applies a partial function to the elements of this collection, returning the first result wrapped in an Option if the partial function is defined for that element.
Applies a partial function to the elements of this collection, returning the first result wrapped in an Option if the partial function is defined for that element.
Attributes
- Source
- Chunk.scala
Transforms all elements of the chunk for as long as the specified partial function is defined.
Transforms all elements of the chunk for as long as the specified partial function is defined.
Attributes
- Source
- Chunk.scala
Determines whether this chunk and the specified chunk have the same length and every pair of corresponding elements of this chunk and the specified chunk satisfy the specified predicate.
Determines whether this chunk and the specified chunk have the same length and every pair of corresponding elements of this chunk and the specified chunk satisfy the specified predicate.
Attributes
- Source
- Chunk.scala
Deduplicates adjacent elements that are identical.
Returns a new NonEmptyChunk containing distinct elements from this NonEmptyChunk. Duplicate elements are removed, preserving the order of their first occurrence.
Returns a new NonEmptyChunk containing distinct elements from this NonEmptyChunk. Duplicate elements are removed, preserving the order of their first occurrence.
Attributes
- Source
- Chunk.scala
Get the element at the specified index.
Drops all elements until the predicate returns true.
Returns whether this NonEmptyChunk and the specified NonEmptyChunk are equal to each other.
Returns whether this NonEmptyChunk and the specified NonEmptyChunk are equal to each other.
Attributes
- Definition Classes
-
Any
- Source
- Chunk.scala
Determines whether a predicate is satisfied for at least one element of this NonEmptyChunk.
Determines whether a predicate is satisfied for at least one element of this NonEmptyChunk.
Attributes
- Source
- Chunk.scala
Filters the elements of this chunk based on the predicate provided.
Returns a new Chunk that contains all elements of this NonEmptyChunk except those for which the given predicate p returns true.
Returns a new Chunk that contains all elements of this NonEmptyChunk except those for which the given predicate p returns true.
Attributes
- Source
- Chunk.scala
Searches for the first element that satisfies the given predicate p.
Maps each element of this NonEmptyChunk to a new NonEmptyChunk and then concatenates them together.
Maps each element of this NonEmptyChunk to a new NonEmptyChunk and then concatenates them together.
Attributes
- Source
- Chunk.scala
Flattens a NonEmptyChunk of NonEmptyChunk values to a single NonEmptyChunk.
Flattens a NonEmptyChunk of NonEmptyChunk values to a single NonEmptyChunk.
Attributes
- Source
- Chunk.scala
Get the element at the specified index.
Applies a binary operator to a start value and all elements of this collection, going left to right, to reduce the elements to a single value.
Applies a binary operator to a start value and all elements of this collection, going left to right, to reduce the elements to a single value.
Attributes
- Source
- Chunk.scala
Folds over the elements in this chunk from the left. Stops the fold early when the condition is not fulfilled.
Folds over the elements in this chunk from the left. Stops the fold early when the condition is not fulfilled.
Attributes
- Source
- Chunk.scala
Tests whether a predicate holds for all elements in the chunk.
Groups the values in this NonEmptyChunk using the specified function.
Groups and transformers the values in this NonEmptyChunk using the specified function.
Groups and transformers the values in this NonEmptyChunk using the specified function.
Attributes
- Source
- Chunk.scala
Splits this NonEmptyChunk into groups of up to the specified size, returning an iterator of NonEmptyChunk instances.
Splits this NonEmptyChunk into groups of up to the specified size, returning an iterator of NonEmptyChunk instances.
Attributes
- Source
- Chunk.scala
Returns the hashcode of this NonEmptyChunk.
Retrieves the first element of the collection chunk.
Returns a new chunk containing all elements except the last one. If the chunk is empty, this method throws an exception.
Returns a new chunk containing all elements except the last one. If the chunk is empty, this method throws an exception.
Attributes
- Source
- Chunk.scala
Get the element at the specified index.
Provides an iterator to traverse through the elements of the chunk.
Retrieves the last element of a non-empty chunk.
Get the element at the specified index.
Transforms the elements of this NonEmptyChunk with the specified function.
Transforms the elements of this NonEmptyChunk with the specified function.
Attributes
- Source
- Chunk.scala
Statefully maps over the chunk, producing new elements of type B.
Maps over the elements of this NonEmptyChunk, maintaining some state along the way.
Maps over the elements of this NonEmptyChunk, maintaining some state along the way.
Attributes
- Source
- Chunk.scala
Materializes a chunk into a chunk backed by an array. This method can improve the performance of bulk operations.
Materializes a chunk into a chunk backed by an array. This method can improve the performance of bulk operations.
Attributes
- Source
- Chunk.scala
Materialize the elements of this NonEmptyChunk into a NonEmptyChunk backed by an array.
Materialize the elements of this NonEmptyChunk into a NonEmptyChunk backed by an array.
Attributes
- Source
- Chunk.scala
Returns the bitwise NOT of this chunk.
Runs fn if a chunk is not empty or returns the default value.
Prepends a single element to the beginning of this NonEmptyChunk.
Reduces the elements of this collection using the specified binary operator.
Reduces the elements of this collection using the specified binary operator.
Attributes
- Source
- Chunk.scala
Reduces the elements of this NonEmptyChunk from left to right using the function map to transform the first value to the type B and then the function reduce to combine the B value with each other A value.
Reduces the elements of this NonEmptyChunk from left to right using the function map to transform the first value to the type B and then the function reduce to combine the B value with each other A value.
Attributes
- Source
- Chunk.scala
Reduces the elements of this NonEmptyChunk from right to left using the function map to transform the first value to the type B and then the function reduce to combine the B value with each other A value.
Reduces the elements of this NonEmptyChunk from right to left using the function map to transform the first value to the type B and then the function reduce to combine the B value with each other A value.
Attributes
- Source
- Chunk.scala
Attributes
- Source
- Chunk.scala
Get the element at the specified index.
Returns the size of the chunk.
Returns a new NonEmptyChunk containing all elements of this NonEmptyChunk sorted according to the values produced by the given function f.
Returns a new NonEmptyChunk containing all elements of this NonEmptyChunk sorted according to the values produced by the given function f.
Attributes
- Source
- Chunk.scala
Returns a new NonEmptyChunk containing all elements of this NonEmptyChunk sorted according to the provided implicit Ordering.
Returns a new NonEmptyChunk containing all elements of this NonEmptyChunk sorted according to the provided implicit Ordering.
Attributes
- Source
- Chunk.scala
Splits this chunk into n equally sized chunks.
Splits this chunk on the first element that matches this predicate.
Returns a new Chunk instance representing the tail of the current chunk. The tail contains all elements except the first one.
Returns a new Chunk instance representing the tail of the current chunk. The tail contains all elements except the first one.
Attributes
- Source
- Chunk.scala
Converts this NonEmptyChunk to an array.
Renders this chunk of bits as a binary string.
Converts this NonEmptyChunk to a Chunk, discarding information about it not being empty.
Converts this NonEmptyChunk to a Chunk, discarding information about it not being empty.
Attributes
- Source
- Chunk.scala
Converts this NonEmptyChunk to the :: case of a List.
Converts this NonEmptyChunk to an Iterable.
Converts this NonEmptyChunk to a List.
Converts a chunk of Boolean values into a packed Byte representation.
Converts a chunk of Boolean values into a packed Int representation.
Converts a chunk of Boolean values into a packed Long representation.
Renders this NonEmptyChunk as a String.
Zips this chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk. The returned chunk will have the length of the shorter chunk.
Zips this chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk. The returned chunk will have the length of the shorter chunk.
Attributes
- Source
- Chunk.scala
Zips this NonEmptyChunk with the specified NonEmptyChunk, only keeping as many elements as are in the smaller chunk.
Zips this NonEmptyChunk with the specified NonEmptyChunk, only keeping as many elements as are in the smaller chunk.
Attributes
- Source
- Chunk.scala
Zips this chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk, filling in missing values from the shorter chunk with None. The returned chunk will have the length of the longer chunk.
Zips this chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk, filling in missing values from the shorter chunk with None. The returned chunk will have the length of the longer chunk.
Attributes
- Source
- Chunk.scala
Zips this NonEmptyChunk with the specified Chunk, using None to "fill in" missing values if one chunk has fewer elements than the other.
Zips this NonEmptyChunk with the specified Chunk, using None to "fill in" missing values if one chunk has fewer elements than the other.
Attributes
- Source
- Chunk.scala
Zips with chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk combined using the specified function both. If one chunk is shorter than the other, uses the specified function left or right to map the element that does exist to the result type.
Zips with chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk combined using the specified function both. If one chunk is shorter than the other, uses the specified function left or right to map the element that does exist to the result type.
Attributes
- Source
- Chunk.scala
Zips this NonEmptyChunk with the specified Chunk, using the specified functions to "fill in" missing values if one chunk has fewer elements than the other.
Zips this NonEmptyChunk with the specified Chunk, using the specified functions to "fill in" missing values if one chunk has fewer elements than the other.
Attributes
- Source
- Chunk.scala
Zips this chunk with the specified chunk using the specified combiner.
Zips this chunk with the specified chunk using the specified combiner.
Attributes
- Source
- Chunk.scala
Zips this NonEmptyChunk with the specified NonEmptyChunk, only keeping as many elements as are in the smaller chunk.
Zips this NonEmptyChunk with the specified NonEmptyChunk, only keeping as many elements as are in the smaller chunk.
Attributes
- Source
- Chunk.scala
Annotates each element of this NonEmptyChunk with its index.
Zips this chunk with the index of every element, starting from the initial index value.
Zips this chunk with the index of every element, starting from the initial index value.
Attributes
- Source
- Chunk.scala
Annotates each element of this NonEmptyChunk with its index, with the specified offset.
Annotates each element of this NonEmptyChunk with its index, with the specified offset.
Attributes
- Source
- Chunk.scala
Returns the bitwise OR of this chunk and the specified chunk.
Inherited methods
Alias for concat.
Alias for concat.
Type parameters
- B
-
the element type of the returned collection
Value parameters
- suffix
-
the iterable to append to this immutable sequence
Attributes
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Alias for prepended.
Alias for prepended.
Note that :-ending operators are right associative (see example). A mnemonic for +: vs. :+ is: the COLon goes on the COLlection side.
Attributes
- Returns
-
a new immutable sequence consisting of
elemfollowed by all elements of this immutable sequence - Inherited from:
- SeqOps
- Source
- Seq.scala
Appends all elements of this immutable sequence to a string builder. The written text consists of the string representations (w.r.t. the method toString) of all elements of this immutable sequence without any separator string.
Appends all elements of this immutable sequence to a string builder. The written text consists of the string representations (w.r.t. the method toString) of all elements of this immutable sequence without any separator string.
Example:
val a = List(1,2,3,4) // List(1, 2, 3, 4)
val b = new StringBuilder()
val h = a.addString(b) // 1234
Value parameters
- b
-
the string builder to which elements are appended.
Attributes
- Returns
-
the string builder
bto which elements were appended. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Appends all elements of this immutable sequence to a string builder using a separator string. The written text consists of the string representations (w.r.t. the method toString) of all elements of this immutable sequence, separated by the string sep.
Appends all elements of this immutable sequence to a string builder using a separator string. The written text consists of the string representations (w.r.t. the method toString) of all elements of this immutable sequence, separated by the string sep.
Example:
val a = List(1,2,3,4) // List(1, 2, 3, 4)
val b = new StringBuilder()
a.addString(b, ", ") // 1, 2, 3, 4
Value parameters
- b
-
the string builder to which elements are appended.
- sep
-
the separator string.
Attributes
- Returns
-
the string builder
bto which elements were appended. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Appends all elements of this immutable sequence to a string builder using start, end, and separator strings. The written text begins with the string start and ends with the string end. Inside, the string representations (w.r.t. the method toString) of all elements of this immutable sequence are separated by the string sep.
Appends all elements of this immutable sequence to a string builder using start, end, and separator strings. The written text begins with the string start and ends with the string end. Inside, the string representations (w.r.t. the method toString) of all elements of this immutable sequence are separated by the string sep.
Example:
val a = List(1,2,3,4) // List(1, 2, 3, 4)
val b = new StringBuilder()
a.addString(b , "List(" , ", " , ")") // List(1, 2, 3, 4)
Value parameters
- b
-
the string builder to which elements are appended.
- end
-
the ending string.
- sep
-
the separator string.
- start
-
the starting string.
Attributes
- Returns
-
the string builder
bto which elements were appended. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Composes this partial function with another partial function that gets applied to results of this partial function.
Composes this partial function with another partial function that gets applied to results of this partial function.
Note that calling isDefinedAt on the resulting partial function may apply the first partial function and execute its side effect. For efficiency, it is recommended to call applyOrElse instead of isDefinedAt or apply.
Type parameters
- C
-
the result type of the transformation function.
Value parameters
- k
-
the transformation function
Attributes
- Returns
-
a partial function with the domain of this partial function narrowed by other partial function, which maps arguments
xtok(this(x)). - Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Applies this partial function to the given argument when it is contained in the function domain. Applies fallback function where this partial function is not defined.
Applies this partial function to the given argument when it is contained in the function domain. Applies fallback function where this partial function is not defined.
Note that expression pf.applyOrElse(x, default) is equivalent to if(pf isDefinedAt x) pf(x) else default(x) except that applyOrElse method can be implemented more efficiently. For all partial function literals the compiler generates an applyOrElse implementation which avoids double evaluation of pattern matchers and guards. This makes applyOrElse the basis for the efficient implementation for many operations and scenarios, such as:
- combining partial functions into
orElse/andThenchains does not lead to excessiveapply/isDefinedAtevaluation liftandunliftdo not evaluate source functions twice on each invocationrunWithallows efficient imperative-style combining of partial functions with conditionally applied actions
For non-literal partial function classes with nontrivial isDefinedAt method it is recommended to override applyOrElse with custom implementation that avoids double isDefinedAt evaluation. This may result in better performance and more predictable behavior w.r.t. side effects.
@param x the function argument @param default the fallback function @return the result of this function or fallback function application.
Attributes
- Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Finds the first element of the immutable sequence for which the given partial function is defined, and applies the partial function to it.
Finds the first element of the immutable sequence for which the given partial function is defined, and applies the partial function to it.
Note: may not terminate for infinite-sized collections.
Type parameters
- B
-
the result type of the partial function
Value parameters
- pf
-
the partial function
Attributes
- Returns
-
an option value containing pf applied to the first value for which it is defined, or
Noneif none exists. - Example
-
Seq("a", 1, 5L).collectFirst { case x: Int => x*10 } = Some(10) - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Iterates over combinations of elements.
Iterates over combinations of elements.
A combination of length n is a sequence of n elements selected in order of their first index in this sequence.
For example, "xyx" has two combinations of length 2. The x is selected first: "xx", "xy". The sequence "yx" is not returned as a combination because it is subsumed by "xy".
If there is more than one way to generate the same combination, only one will be returned.
For example, the result "xy" arbitrarily selected one of the x elements.
As a further illustration, "xyxx" has three different ways to generate "xy" because there are three elements x to choose from. Moreover, there are three unordered pairs "xx" but only one is returned.
It is not specified which of these equal combinations is returned. It is an implementation detail that should not be relied on. For example, the combination "xx" does not necessarily contain the first x in this sequence. This behavior is observable if the elements compare equal but are not identical.
As a consequence, "xyx".combinations(3).next() is "xxy": the combination does not reflect the order of the original sequence, but the order in which elements were selected, by "first index"; the order of each x element is also arbitrary.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Value parameters
- n
-
the number of elements in each combination
Attributes
- Returns
-
An Iterator which traverses the n-element combinations of this immutable sequence.
- Example
-
Seq('a', 'b', 'b', 'b', 'c').combinations(2).foreach(println) // List(a, b) // List(a, c) // List(b, b) // List(b, c) Seq('b', 'a', 'b').combinations(2).foreach(println) // List(b, b) // List(b, a) - Inherited from:
- SeqOps
- Source
- Seq.scala
Composes another partial function k with this partial function so that this partial function gets applied to results of k.
Composes another partial function k with this partial function so that this partial function gets applied to results of k.
Note that calling isDefinedAt on the resulting partial function may apply the first partial function and execute its side effect. For efficiency, it is recommended to call applyOrElse instead of isDefinedAt or apply.
Type parameters
- R
-
the parameter type of the transformation function.
Value parameters
- k
-
the transformation function
Attributes
- Returns
-
a partial function with the domain of other partial function narrowed by this partial function, which maps arguments
xtothis(k(x)). - Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Composes two instances of Function1 in a new Function1, with this function applied last.
Composes two instances of Function1 in a new Function1, with this function applied last.
Type parameters
- A
-
the type to which function
gcan be applied
Value parameters
- g
-
a function A => T1
Attributes
- Returns
-
a new function
fsuch thatf(x) == apply(g(x)) - Inherited from:
- Function1
- Source
- Function1.scala
Tests whether this immutable sequence contains a given value as an element.
Tests whether this immutable sequence contains a given value as an element.
Note: may not terminate for infinite-sized collections.
Type parameters
- A1
-
the type of the element to test (a supertype of
A)
Value parameters
- elem
-
the element to test.
Attributes
- Returns
-
trueif this immutable sequence has an element that is equal (as determined by==) toelem,falseotherwise. - Inherited from:
- SeqOps
- Source
- Seq.scala
Tests whether this immutable sequence contains a given sequence as a slice.
Tests whether this immutable sequence contains a given sequence as a slice.
Note: may not terminate for infinite-sized collections.
Type parameters
- B
-
the element type used for comparison (a supertype of
A)
Value parameters
- that
-
the sequence to test
Attributes
- Returns
-
trueif this immutable sequence contains a slice with the same elements asthat, otherwisefalse. - Inherited from:
- SeqOps
- Source
- Seq.scala
Copies elements to an array, returning the number of elements written.
Copies elements to an array, returning the number of elements written.
Fills the given array dest starting at index start with values of this immutable sequence.
Copying will stop once either all the elements of this immutable sequence have been copied, or the end of the array is reached.
Type parameters
- B
-
the type of the elements of the array.
Value parameters
- dest
-
the array to fill.
- start
-
the starting index of xs.
Attributes
- Returns
-
the number of elements written to the array
- Note
-
Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Copies elements to an array, returning the number of elements written.
Copies elements to an array, returning the number of elements written.
Fills the given array dest starting at index start with values of this immutable sequence.
Copying will stop once either all the elements of this immutable sequence have been copied, or the end of the array is reached.
Type parameters
- B
-
the type of the elements of the array.
Value parameters
- dest
-
the array to fill.
Attributes
- Returns
-
the number of elements written to the array
- Note
-
Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Tests whether every element of this collection's iterator relates to the corresponding element of another collection by satisfying a test predicate.
Tests whether every element of this collection's iterator relates to the corresponding element of another collection by satisfying a test predicate.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
the type of the elements of
that
Value parameters
- p
-
the test predicate, which relates elements from both collections
- that
-
the other collection
Attributes
- Returns
-
trueif both collections have the same length andp(x, y)istruefor all corresponding elementsxof this iterator andyofthat, otherwisefalse - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Tests whether every element of this immutable sequence relates to the corresponding element of another sequence by satisfying a test predicate.
Tests whether every element of this immutable sequence relates to the corresponding element of another sequence by satisfying a test predicate.
Type parameters
- B
-
the type of the elements of
that
Value parameters
- p
-
the test predicate, which relates elements from both sequences
- that
-
the other sequence
Attributes
- Returns
-
trueif both sequences have the same length andp(x, y)istruefor all corresponding elementsxof this immutable sequence andyofthat, otherwisefalse. - Inherited from:
- SeqOps
- Source
- Seq.scala
Counts the number of elements in the immutable sequence which satisfy a predicate.
Counts the number of elements in the immutable sequence which satisfy a predicate.
Note: will not terminate for infinite-sized collections.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the number of elements satisfying the predicate
p. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Selects all the elements of this immutable sequence ignoring the duplicates.
Selects all the elements of this immutable sequence ignoring the duplicates.
Attributes
- Returns
-
a new immutable sequence consisting of all the elements of this immutable sequence without duplicates.
- Inherited from:
- SeqOps
- Source
- Seq.scala
Returns an extractor object with a unapplySeq method, which extracts each element of a sequence data.
Returns an extractor object with a unapplySeq method, which extracts each element of a sequence data.
Attributes
- Example
-
val firstChar: String => Option[Char] = _.headOption Seq("foo", "bar", "baz") match { case firstChar.unlift.elementWise(c0, c1, c2) => println(s"$c0, $c1, $c2") // Output: f, b, b } - Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Tests whether this immutable sequence ends with the given sequence.
Tests whether this immutable sequence ends with the given sequence.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
the element type used for comparison (a supertype of
A)
Value parameters
- that
-
the sequence to test
Attributes
- Returns
-
trueif this immutable sequence hasthatas a suffix,falseotherwise. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds the last element of the immutable sequence satisfying a predicate, if any.
Finds the last element of the immutable sequence satisfying a predicate, if any.
Note: will not terminate for infinite-sized collections.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
an option value containing the last element in the immutable sequence that satisfies
p, orNoneif none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Applies the given binary operator op to the given initial value z and all elements of this immutable sequence.
Applies the given binary operator op to the given initial value z and all elements of this immutable sequence.
For each application of the operator, each operand is either an element of this immutable sequence, the initial value, or another such application of the operator.
The order of applications of the operator is unspecified and may be nondeterministic.
Each element appears exactly once in the computation.
The initial value may be used an arbitrary number of times, but at least once.
If this collection is ordered, then for any application of the operator, the element(s) appearing in the left operand will precede those in the right.
Note: might return different results for different runs, unless either
of the following conditions is met: (1) the operator is associative,
and the underlying collection type is ordered; or (2) the operator is
associative and commutative. In either case, it is also necessary that the initial value
be a neutral value for the operator, e.g. Nil for List concatenation or 1 for multiplication.
The default implementation in IterableOnce is equivalent to foldLeft but may be overridden for more efficient traversal orders.
Note: will not terminate for infinite-sized collections.
Type parameters
- A1
-
The type parameter for the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator; must be associative for the result to always be the same across runs.
- z
-
An initial value; may be used an arbitrary number of times in the computation of the result; must be a neutral value for
opfor the result to always be the same across runs.
Attributes
- Returns
-
The result of applying
opbetween all the elements andz, orzif this immutable sequence is empty. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Applies f to each element for its side effects. Note: U parameter needed to help scalac's type inference.
Applies f to each element for its side effects. Note: U parameter needed to help scalac's type inference.
Type parameters
- U
-
the return type of
f; the value is discarded, but the type parameter aids type inference
Value parameters
- f
-
the function to apply to each element for its side effects
Attributes
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Defines how to turn a given Iterable[A] into a collection of type C.
Defines how to turn a given Iterable[A] into a collection of type C.
This process can be done in a strict way or a non-strict way (ie. without evaluating the elements of the resulting collections). In other words, this methods defines the evaluation model of the collection.
Value parameters
- coll
-
the source collection to convert
Attributes
- Returns
-
a new collection of type
Ccontaining the elements ofcoll - Note
-
When implementing a custom collection type and refining
Cto the new type, this method needs to be overridden (the compiler will issue an error otherwise). In the common case whereC =:= CC[A], this can be done by mixing in the scala.collection.IterableFactoryDefaults trait, which implements the method using iterableFactory.As witnessed by the
@uncheckedVarianceannotation, using this method might be unsound. However, as long as it is called with anIterable[A]obtained fromthiscollection (as it is the case in the implementations of operations where we use aView[A]), it is safe. - Inherited from:
- IterableFactoryDefaults
- Source
- Iterable.scala
Partitions this immutable sequence into a map of immutable sequences according to some discriminator function.
Partitions this immutable sequence into a map of immutable sequences according to some discriminator function.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Type parameters
- K
-
the type of keys returned by the discriminator function.
Value parameters
- f
-
the discriminator function.
Attributes
- Returns
-
A map from keys to immutable sequences such that the following invariant holds:
(xs groupBy f)(k) = xs filter (x => f(x) == k)That is, every key `k` is bound to a immutable sequence of those elements `x` for which `f(x)` equals `k`. - Inherited from:
- IterableOps
- Source
- Iterable.scala
Partitions this immutable sequence into a map of immutable sequences according to a discriminator function key. Each element in a group is transformed into a value of type B using the value function.
Partitions this immutable sequence into a map of immutable sequences according to a discriminator function key. Each element in a group is transformed into a value of type B using the value function.
It is equivalent to groupBy(key).mapValues(_.map(f)), but more efficient.
case class User(name: String, age: Int)
def namesByAge(users: Seq[User]): Map[Int, Seq[String]] =
users.groupMap(_.age)(_.name)
Note: Even when applied to a view or a lazy collection it will always force the elements.
Type parameters
- B
-
the type of values returned by the transformation function
- K
-
the type of keys returned by the discriminator function
Value parameters
- f
-
the element transformation function
- key
-
the discriminator function
Attributes
- Returns
-
a map associating each key
kproduced bykeywith a immutable sequence of values produced by applyingfto elements that map tok - Inherited from:
- IterableOps
- Source
- Iterable.scala
Partitions this immutable sequence into a map according to a discriminator function key. All the values that have the same discriminator are then transformed by the f function and then reduced into a single value with the reduce function.
Partitions this immutable sequence into a map according to a discriminator function key. All the values that have the same discriminator are then transformed by the f function and then reduced into a single value with the reduce function.
It is equivalent to groupBy(key).mapValues(_.map(f).reduce(reduce)), but more efficient.
def occurrences[A](as: Seq[A]): Map[A, Int] =
as.groupMapReduce(identity)(_ => 1)(_ + _)
Note: Even when applied to a view or a lazy collection it will always force the elements.
Type parameters
- B
-
the type of values returned by the transformation function
- K
-
the type of keys returned by the discriminator function
Value parameters
- f
-
the element transformation function
- key
-
the discriminator function
- reduce
-
the reduction function used to combine values mapped to the same key
Attributes
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Partitions elements in fixed size immutable sequences.
Partitions elements in fixed size immutable sequences.
Value parameters
- size
-
the number of elements per group
Attributes
- Returns
-
An iterator producing immutable sequences of size
size, except the last will be less than sizesizeif the elements don't divide evenly. - See also
-
scala.collection.Iterator, method
grouped - Inherited from:
- IterableOps
- Source
- Iterable.scala
Finds index of first occurrence of some value in this immutable sequence.
Finds index of first occurrence of some value in this immutable sequence.
Type parameters
- B
-
the type of the element
elem.
Value parameters
- elem
-
the element value to search for.
Attributes
- Returns
-
the index
>= 0of the first element of this immutable sequence that is equal (as determined by==) toelem, or-1, if none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds index of first occurrence of some value in this immutable sequence after or at some start index.
Finds index of first occurrence of some value in this immutable sequence after or at some start index.
Type parameters
- B
-
the type of the element
elem.
Value parameters
- elem
-
the element value to search for.
- from
-
the start index
Attributes
- Returns
-
the index
>= fromof the first element of this immutable sequence that is equal (as determined by==) toelem, or-1, if none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds first index where this immutable sequence contains a given sequence as a slice.
Finds first index where this immutable sequence contains a given sequence as a slice.
Note: may not terminate for infinite-sized collections.
Value parameters
- that
-
the sequence to test
Attributes
- Returns
-
the first index
>= 0such that the elements of this immutable sequence starting at this index match the elements of sequencethat, or-1if no such subsequence exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds first index after or at a start index where this immutable sequence contains a given sequence as a slice.
Finds first index after or at a start index where this immutable sequence contains a given sequence as a slice.
Note: may not terminate for infinite-sized collections.
Type parameters
- B
-
the element type used for comparison (a supertype of
A)
Value parameters
- from
-
the start index
- that
-
the sequence to test
Attributes
- Returns
-
the first index
>= fromsuch that the elements of this immutable sequence starting at this index match the elements of sequencethat, or-1if no such subsequence exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds index of the first element satisfying some predicate.
Finds index of the first element satisfying some predicate.
Note: may not terminate for infinite-sized collections.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the index
>= 0of the first element of this immutable sequence that satisfies the predicatep, or-1, if none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Produces the range of all indices of this sequence.
Produces the range of all indices of this sequence.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Attributes
- Returns
-
a
Rangevalue from0to one less than the length of this immutable sequence. - Inherited from:
- SeqOps
- Source
- Seq.scala
The initial part of the collection without its last element.
The initial part of the collection without its last element.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Attributes
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Iterates over the inits of this immutable sequence. The first value will be this immutable sequence and the final one will be an empty immutable sequence, with the intervening values the results of successive applications of init.
Iterates over the inits of this immutable sequence. The first value will be this immutable sequence and the final one will be an empty immutable sequence, with the intervening values the results of successive applications of init.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Attributes
- Returns
-
an iterator over all the inits of this immutable sequence
- Example
-
List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil) - Inherited from:
- IterableOps
- Source
- Iterable.scala
Tests whether this immutable sequence contains given index.
Tests whether this immutable sequence contains given index.
The implementations of methods apply and isDefinedAt turn a Seq[A] into a PartialFunction[Int, A].
Value parameters
- idx
-
the index to test
Attributes
- Returns
-
trueif this immutable sequence contains an element at positionidx,falseotherwise. - Inherited from:
- SeqOps
- Source
- Seq.scala
An scala.collection.Iterator over the elements of this immutable sequence.
An scala.collection.Iterator over the elements of this immutable sequence.
If an IterableOnce object is in fact an scala.collection.Iterator, this method always returns itself, in its current state, but if it is an scala.collection.Iterable, this method always returns a new scala.collection.Iterator.
Attributes
- Returns
-
an iterator over all elements of this immutable sequence
- Inherited from:
- IndexedSeqOps
- Source
- IndexedSeq.scala
Finds index of last occurrence of some value in this immutable sequence before or at a given end index.
Finds index of last occurrence of some value in this immutable sequence before or at a given end index.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
the type of the element
elem.
Value parameters
- elem
-
the element value to search for.
- end
-
the end index.
Attributes
- Returns
-
the index
<= endof the last element of this immutable sequence that is equal (as determined by==) toelem, or-1, if none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds last index where this immutable sequence contains a given sequence as a slice.
Finds last index where this immutable sequence contains a given sequence as a slice.
Note: will not terminate for infinite-sized collections.
Value parameters
- that
-
the sequence to test
Attributes
- Returns
-
the last index such that the elements of this immutable sequence starting at this index match the elements of sequence
that, or-1if no such subsequence exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds last index before or at a given end index where this immutable sequence contains a given sequence as a slice.
Finds last index before or at a given end index where this immutable sequence contains a given sequence as a slice.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
the element type used for comparison (a supertype of
A)
Value parameters
- end
-
the end index
- that
-
the sequence to test
Attributes
- Returns
-
the last index
<= endsuch that the elements of this immutable sequence starting at this index match the elements of sequencethat, or-1if no such subsequence exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Finds index of last element satisfying some predicate.
Finds index of last element satisfying some predicate.
Note: will not terminate for infinite-sized collections.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the index of the last element of this immutable sequence that satisfies the predicate
p, or-1, if none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
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.
Note: will not terminate for infinite-sized collections.
Value parameters
- end
-
the maximum index to consider (inclusive)
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the index
<= endof the last element of this immutable sequence that satisfies the predicatep, or-1, if none exists. - Inherited from:
- SeqOps
- Source
- Seq.scala
Analogous to zip except that the elements in each collection are not consumed until a strict operation is invoked on the returned LazyZip2 decorator.
Analogous to zip except that the elements in each collection are not consumed until a strict operation is invoked on the returned LazyZip2 decorator.
Calls to lazyZip can be chained to support higher arities (up to 4) without incurring the expense of constructing and deconstructing intermediary tuples.
val xs = List(1, 2, 3)
val res = (xs lazyZip xs lazyZip xs lazyZip xs).map((a, b, c, d) => a + b + c + d)
// res == List(4, 8, 12)
Type parameters
- B
-
the type of the second element in each eventual pair
Value parameters
- that
-
the iterable providing the second element of each eventual pair
Attributes
- Returns
-
a decorator
LazyZip2that allows strict operations to be performed on the lazily evaluated pairs or chained calls tolazyZip. Implicit conversion toIterable[(A, B)]is also supported. - Inherited from:
- Iterable
- Source
- Iterable.scala
Returns a value class containing operations for comparing the length of this immutable sequence to a test value.
Returns a value class containing operations for comparing the length of this immutable sequence to a test value.
These operations are implemented in terms of `lengthCompare(Int)`, and allow the following more readable usages:
this.lengthIs < len // this.lengthCompare(len) < 0
this.lengthIs <= len // this.lengthCompare(len) <= 0
this.lengthIs == len // this.lengthCompare(len) == 0
this.lengthIs != len // this.lengthCompare(len) != 0
this.lengthIs >= len // this.lengthCompare(len) >= 0
this.lengthIs > len // this.lengthCompare(len) > 0
Attributes
- Returns
-
an object providing
=, and>operations for comparing the length - Inherited from:
- SeqOps
- Source
- Seq.scala
Turns this partial function into a plain function returning an Option result.
Turns this partial function into a plain function returning an Option result.
Attributes
- Returns
-
a function that takes an argument
xtoSome(this(x))ifthisis defined forx, and toNoneotherwise. - See also
-
Function.unlift
- Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Finds the largest element.
Finds the largest element.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The type over which the ordering is defined.
Value parameters
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
the largest element of this immutable sequence with respect to the ordering
ord. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the first element which yields the largest value measured by function f.
Finds the first element which yields the largest value measured by function f.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the function
f.
Value parameters
- f
-
The measuring function.
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
the first element of this immutable sequence with the largest value measured by function
fwith respect to the orderingord. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the first element which yields the largest value measured by function f.
Finds the first element which yields the largest value measured by function f.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the function
f.
Value parameters
- f
-
The measuring function.
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
an option value containing the first element of this immutable sequence with the largest value measured by function
fwith respect to the orderingord. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the largest element.
Finds the largest element.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The type over which the ordering is defined.
Value parameters
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
an option value containing the largest element of this immutable sequence with respect to the ordering
ord. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the smallest element.
Finds the smallest element.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The type over which the ordering is defined.
Value parameters
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
the smallest element of this immutable sequence with respect to the ordering
ord. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the first element which yields the smallest value measured by function f.
Finds the first element which yields the smallest value measured by function f.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the function
f.
Value parameters
- f
-
The measuring function.
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
the first element of this immutable sequence with the smallest value measured by function
fwith respect to the orderingord. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the first element which yields the smallest value measured by function f.
Finds the first element which yields the smallest value measured by function f.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the function
f.
Value parameters
- f
-
The measuring function.
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
an option value containing the first element of this immutable sequence with the smallest value measured by function
fwith respect to the orderingord. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Finds the smallest element.
Finds the smallest element.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The type over which the ordering is defined.
Value parameters
- ord
-
An ordering to be used for comparing elements.
Attributes
- Returns
-
an option value containing the smallest element of this immutable sequence with respect to the ordering
ord. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Displays all elements of this immutable sequence in a string.
Displays all elements of this immutable sequence in a string.
Delegates to addString, which can be overridden.
Attributes
- Returns
-
a string representation of this immutable sequence. In the resulting string the string representations (w.r.t. the method
toString) of all elements of this immutable sequence follow each other without any separator string. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Displays all elements of this immutable sequence in a string using a separator string.
Displays all elements of this immutable sequence in a string using a separator string.
Delegates to addString, which can be overridden.
Value parameters
- sep
-
the separator string.
Attributes
- Returns
-
a string representation of this immutable sequence. In the resulting string the string representations (w.r.t. the method
toString) of all elements of this immutable sequence are separated by the stringsep. - Example
-
List(1, 2, 3).mkString("|") = "1|2|3" - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Displays all elements of this immutable sequence in a string using start, end, and separator strings.
Displays all elements of this immutable sequence in a string using start, end, and separator strings.
Delegates to addString, which can be overridden.
Value parameters
- end
-
the ending string.
- sep
-
the separator string.
- start
-
the starting string.
Attributes
- Returns
-
a string representation of this immutable sequence. The resulting string begins with the string
startand ends with the stringend. Inside, the string representations (w.r.t. the methodtoString) of all elements of this immutable sequence are separated by the stringsep. - Example
-
List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)" - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Note that in the case of lazy collections (e.g. scala.collection.View or scala.collection.immutable.LazyList),
Note that in the case of lazy collections (e.g. scala.collection.View or scala.collection.immutable.LazyList),
Attributes
- Returns
-
a strict builder for the same collection type. it is possible to implement this method but the resulting
Builderwill break laziness. As a consequence, operations should preferably be implemented withfromSpecificinstead of this method. - Note
-
When implementing a custom collection type and refining
Cto the new type, this method needs to be overridden (the compiler will issue an error otherwise). In the common case whereC =:= CC[A], this can be done by mixing in the scala.collection.IterableFactoryDefaults trait, which implements the method using iterableFactory.As witnessed by the
@uncheckedVarianceannotation, using this method might be unsound. However, as long as the returned builder is only fed withAvalues taken fromthisinstance, it is safe. - Inherited from:
- IterableFactoryDefaults
- Source
- Iterable.scala
Tests whether the immutable sequence is not empty.
Tests whether the immutable sequence is not empty.
Attributes
- Returns
-
trueif the immutable sequence contains at least one element,falseotherwise. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Composes this partial function with a fallback partial function which gets applied where this partial function is not defined.
Composes this partial function with a fallback partial function which gets applied where this partial function is not defined.
Type parameters
- A1
-
the argument type of the fallback function
- B1
-
the result type of the fallback function
Value parameters
- that
-
the fallback function
Attributes
- Returns
-
a partial function which has as domain the union of the domains of this partial function and
that. The resulting partial function takesxtothis(x)wherethisis defined, and tothat(x)where it is not. - Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Iterates over distinct permutations of elements.
Iterates over distinct permutations of elements.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Attributes
- Returns
-
An Iterator which traverses the distinct permutations of this immutable sequence.
- Example
-
Seq('a', 'b', 'b').permutations.foreach(println) // List(a, b, b) // List(b, a, b) // List(b, b, a) - Inherited from:
- SeqOps
- Source
- Seq.scala
Multiplies together the elements of this collection.
Multiplies together the elements of this collection.
The default implementation uses reduce for a known non-empty collection, foldLeft otherwise.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
the result type of the
*operator.
Value parameters
- num
-
an implicit parameter defining a set of numeric operations which includes the
*operator to be used in forming the product.
Attributes
- Returns
-
the product of all elements of this immutable sequence with respect to the
*operator innum. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Applies the given binary operator op to all elements of this immutable sequence.
Applies the given binary operator op to all elements of this immutable sequence.
For each application of the operator, each operand is either an element of this immutable sequence or another such application of the operator. The order of applications of the operator is unspecified and may be nondeterministic. Each element appears exactly once in the computation.
If this collection is ordered, then for any application of the operator, the element(s) appearing in the left operand will precede those in the right.
Note: might return different results for different runs, unless either
of the following conditions is met: (1) the operator is associative,
and the underlying collection type is ordered; or (2) the operator is
associative and commutative.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The type parameter for the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator; must be associative for the result to always be the same across runs.
Attributes
- Returns
-
The result of applying
opbetween all the elements if the immutable sequence is nonempty. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Applies the given binary operator op to all elements of this immutable sequence, going left to right.
Applies the given binary operator op to all elements of this immutable sequence, going left to right.
"Going left to right" only makes sense if this collection is ordered: then if x,,1,,, x,,2,,, ..., x,,n,, are the elements of this immutable sequence, the result is op( op( op( ... op(x,,1,,, x,,2,,) ... ), x,,n-1,,), x,,n,,).
If this collection is not ordered, then for each application of the operator, each right operand is an element. In addition, the leftmost operand is the first element of this immutable sequence and each other left operand is itself an application of the operator. Each element appears exactly once in the computation.
Note: might return different results for different runs, unless the
underlying collection type is ordered or the operator is associative
and commutative.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator.
Attributes
- Returns
-
The result of applying
opto all elements of this immutable sequence, going left to right. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
If this immutable sequence is nonempty, reduces it with the given binary operator op, going left to right.
If this immutable sequence is nonempty, reduces it with the given binary operator op, going left to right.
The behavior is the same as reduceLeft except that the value is None if the immutable sequence is empty. Each element appears exactly once in the computation.
Note: might return different results for different runs, unless the
underlying collection type is ordered or the operator is associative
and commutative.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator.
Attributes
- Returns
-
The result of reducing this immutable sequence with
opgoing left to right if the immutable sequence is nonempty, inside aSome, andNoneotherwise. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
If this immutable sequence is nonempty, reduces it with the given binary operator op.
If this immutable sequence is nonempty, reduces it with the given binary operator op.
The behavior is the same as reduce except that the value is None if the immutable sequence is empty. The order of applications of the operator is unspecified and may be nondeterministic. Each element appears exactly once in the computation.
Note: might return different results for different runs, unless either
of the following conditions is met: (1) the operator is associative,
and the underlying collection type is ordered; or (2) the operator is
associative and commutative.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
A type parameter for the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator; must be associative for the result to always be the same across runs.
Attributes
- Returns
-
The result of reducing this immutable sequence with
opif the immutable sequence is nonempty, inside aSome, andNoneotherwise. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Applies the given binary operator op to all elements of this immutable sequence, going right to left.
Applies the given binary operator op to all elements of this immutable sequence, going right to left.
"Going right to left" only makes sense if this collection is ordered: then if x,,1,,, x,,2,,, ..., x,,n,, are the elements of this immutable sequence, the result is op(x,,1,,, op(x,,2,,, op( ... op(x,,n-1,,, x,,n,,) ... ))).
If this collection is not ordered, then for each application of the operator, each left operand is an element. In addition, the rightmost operand is the last element of this immutable sequence and each other right operand is itself an application of the operator. Each element appears exactly once in the computation.
Note: might return different results for different runs, unless the
underlying collection type is ordered or the operator is associative
and commutative.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator.
Attributes
- Returns
-
The result of applying
opto all elements of this immutable sequence, going right to left. - Throws
-
UnsupportedOperationException
if this immutable sequence is empty.
- Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
If this immutable sequence is nonempty, reduces it with the given binary operator op, going right to left.
If this immutable sequence is nonempty, reduces it with the given binary operator op, going right to left.
The behavior is the same as reduceRight except that the value is None if the immutable sequence is empty. Each element appears exactly once in the computation.
Note: might return different results for different runs, unless the
underlying collection type is ordered or the operator is associative
and commutative.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
The result type of the binary operator, a supertype of
A.
Value parameters
- op
-
A binary operator.
Attributes
- Returns
-
The result of reducing this immutable sequence with
opgoing right to left if the immutable sequence is nonempty, inside aSome, andNoneotherwise. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Composes this partial function with an action function which gets applied to results of this partial function. The action function is invoked only for its side effects; its result is ignored.
Composes this partial function with an action function which gets applied to results of this partial function. The action function is invoked only for its side effects; its result is ignored.
Note that expression pf.runWith(action)(x) is equivalent to if(pf isDefinedAt x) { action(pf(x)); true } else false except that runWith is implemented via applyOrElse and thus potentially more efficient. Using runWith avoids double evaluation of pattern matchers and guards for partial function literals. @see applyOrElse.
@param action the action function @return a function which maps arguments x to isDefinedAt(x). The resulting function runs action(this(x)) where this is defined.
Attributes
- Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Computes a prefix scan of the elements of the collection.
Computes a prefix scan of the elements of the collection.
Note: The neutral element z may be applied more than once.
Type parameters
- B
-
element type of the resulting collection
Value parameters
- op
-
the associative operator for the scan
- z
-
neutral element for the operator
op
Attributes
- Returns
-
a new immutable sequence containing the prefix scan of the elements in this immutable sequence
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Produces a collection containing cumulative results of applying the operator going right to left. The head of the collection is the last cumulative result.
Produces a collection containing cumulative results of applying the operator going right to left. The head of the collection is the last cumulative result.
Note: will not terminate for infinite-sized collections.
Note: Even when applied to a view or a lazy collection it will always force the elements.
Example:
List(1, 2, 3, 4).scanRight(0)(_ + _) == List(10, 9, 7, 4, 0)
Type parameters
- B
-
the type of the elements in the resulting collection
Value parameters
- op
-
the binary operator applied to the intermediate result and the element
- z
-
the initial value
Attributes
- Returns
-
collection with intermediate results
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Computes the length of the longest segment that starts from some index and whose elements all satisfy some predicate.
Computes the length of the longest segment that starts from some index and whose elements all satisfy some predicate.
Note: may not terminate for infinite-sized collections.
Value parameters
- from
-
the index where the search starts.
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the length of the longest segment of this immutable sequence starting from index
fromsuch that every element of the segment satisfies the predicatep. - Inherited from:
- SeqOps
- Source
- Seq.scala
Computes the length of the longest segment that starts from the first element and whose elements all satisfy some predicate.
Computes the length of the longest segment that starts from the first element and whose elements all satisfy some predicate.
Note: may not terminate for infinite-sized collections.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the length of the longest segment of this immutable sequence that starts from the first element such that every element of the segment satisfies the predicate
p. - Inherited from:
- SeqOps
- Source
- Seq.scala
Returns a value class containing operations for comparing the size of this immutable sequence to a test value.
Returns a value class containing operations for comparing the size of this immutable sequence to a test value.
These operations are implemented in terms of `sizeCompare(Int)`, and allow the following more readable usages:
this.sizeIs < size // this.sizeCompare(size) < 0
this.sizeIs <= size // this.sizeCompare(size) <= 0
this.sizeIs == size // this.sizeCompare(size) == 0
this.sizeIs != size // this.sizeCompare(size) != 0
this.sizeIs >= size // this.sizeCompare(size) >= 0
this.sizeIs > size // this.sizeCompare(size) > 0
Attributes
- Returns
-
a wrapper that allows size comparisons using operators such as
=, and> - Inherited from:
- IterableOps
- Source
- Iterable.scala
Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped).
Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped).
An empty collection returns an empty iterator, and a non-empty collection containing fewer elements than the window size returns an iterator that will produce the original collection as its only element.
Value parameters
- size
-
the number of elements per group
Attributes
- Returns
-
An iterator producing immutable sequences of size
size, except for a non-empty collection with less thansizeelements, which returns an iterator that produces the source collection itself as its only element. - See also
-
scala.collection.Iterator, method
sliding - Example
-
List().sliding(2) = empty iteratorList(1).sliding(2) = Iterator(List(1))List(1, 2).sliding(2) = Iterator(List(1, 2))List(1, 2, 3).sliding(2) = Iterator(List(1, 2), List(2, 3)) - Inherited from:
- IterableOps
- Source
- Iterable.scala
Sorts this immutable sequence according to the Ordering which results from transforming an implicitly given Ordering with a transformation function.
Sorts this immutable sequence according to the Ordering which results from transforming an implicitly given Ordering with a transformation function.
Note: will not terminate for infinite-sized collections.
Note: Even when applied to a view or a lazy collection it will always force the elements.
The sort is stable. That is, elements that are equal (as determined by ord.compare) appear in the same order in the sorted sequence as in the original.
Type parameters
- B
-
the target type of the transformation
f, and the type where the orderingordis defined.
Value parameters
- f
-
the transformation function mapping elements to some other domain
B. - ord
-
the ordering assumed on domain
B.
Attributes
- Returns
-
a immutable sequence consisting of the elements of this immutable sequence sorted according to the ordering where
x < yiford.lt(f(x), f(y)). - See also
-
scala.math.Ordering
- Example
-
val words = "The quick brown fox jumped over the lazy dog".split(' ') // this works because scala.Ordering will implicitly provide an Ordering[Tuple2[Int, Char]] val sorted = words.sortBy(x => (x.length, x.head)) // sorted: Array[String] = Array(The, dog, fox, the, lazy, over, brown, quick, jumped) - Inherited from:
- SeqOps
- Source
- Seq.scala
Sorts this immutable sequence according to a comparison function.
Sorts this immutable sequence according to a comparison function.
Note: will not terminate for infinite-sized collections.
Note: Even when applied to a view or a lazy collection it will always force the elements.
The sort is stable. That is, elements that are equal (lt returns false for both directions of comparison) appear in the same order in the sorted sequence as in the original.
Value parameters
- lt
-
a predicate that is true if its first argument strictly precedes its second argument in the desired ordering.
Attributes
- Returns
-
a immutable sequence consisting of the elements of this immutable sequence sorted according to the comparison function
lt. - Example
-
List("Steve", "Bobby", "Tom", "John", "Bob").sortWith((x, y) => x.take(3).compareTo(y.take(3)) < 0) // List("Bobby", "Bob", "John", "Steve", "Tom") - Inherited from:
- SeqOps
- Source
- Seq.scala
Tests whether this immutable sequence contains the given sequence at a given index.
Tests whether this immutable sequence contains the given sequence at a given index.
Note: If the both the receiver object this and the argument that are infinite sequences this method may not terminate.
Type parameters
- B
-
the element type used for comparison (a supertype of
A)
Value parameters
- offset
-
the index where the sequence is searched.
- that
-
the sequence to test
Attributes
- Returns
-
trueif the sequencethatis contained in this immutable sequence at indexoffset, otherwisefalse. - Inherited from:
- SeqOps
- Source
- Seq.scala
Type parameters
- B
-
Type of elements of the resulting collection (e.g.
String) - C2
-
Type of the resulting collection (e.g.
List[String])
Value parameters
- b
-
Builder to use to build the resulting collection
- pf
-
Element transformation partial function
Attributes
- Returns
-
The resulting collection
- Inherited from:
- StrictOptimizedIterableOps
- Source
- StrictOptimizedIterableOps.scala
Type parameters
- B
-
Type of elements of the resulting collections (e.g.
Int) - C2
-
Type of the resulting collection (e.g.
List[Int])
Value parameters
- b
-
Builder to use to build the resulting collection
- that
-
Elements to concatenate to this collection
Attributes
- Returns
-
The resulting collection
- Inherited from:
- StrictOptimizedIterableOps
- Source
- StrictOptimizedIterableOps.scala
Type parameters
- B
-
Type of elements of the resulting collection (e.g.
String) - C2
-
Type of the resulting collection (e.g.
List[String])
Value parameters
- b
-
Builder to use to build the resulting collection
- f
-
Element transformation function
Attributes
- Returns
-
The resulting collection
- Inherited from:
- StrictOptimizedIterableOps
- Source
- StrictOptimizedIterableOps.scala
Type parameters
- B
-
Type of elements of the resulting collection (e.g.
Int) - C2
-
Type of the resulting collection (e.g.
List[Int])
Value parameters
- b
-
Builder to use to build the resulting collection
- toIterableOnce
-
Evidence that
Acan be seen as anIterableOnce[B]
Attributes
- Returns
-
The resulting collection
- Inherited from:
- StrictOptimizedIterableOps
- Source
- StrictOptimizedIterableOps.scala
Type parameters
- B
-
Type of elements of the resulting collection (e.g.
String) - C2
-
Type of the resulting collection (e.g.
List[String])
Value parameters
- b
-
Builder to use to build the resulting collection
- f
-
Element transformation function
Attributes
- Returns
-
The resulting collection
- Inherited from:
- StrictOptimizedIterableOps
- Source
- StrictOptimizedIterableOps.scala
Type parameters
- B
-
Type of elements of the second collection (e.g.
String) - C2
-
Type of the resulting collection (e.g.
List[(Int, String)])
Value parameters
- b
-
Builder to use to build the resulting collection
- that
-
Collection to zip with this collection
Attributes
- Returns
-
The resulting collection
- Inherited from:
- StrictOptimizedIterableOps
- Source
- StrictOptimizedIterableOps.scala
Sums the elements of this collection.
Sums the elements of this collection.
The default implementation uses reduce for a known non-empty collection, foldLeft otherwise.
Note: will not terminate for infinite-sized collections.
Type parameters
- B
-
the result type of the
+operator.
Value parameters
- num
-
an implicit parameter defining a set of numeric operations which includes the
+operator to be used in forming the sum.
Attributes
- Returns
-
the sum of all elements of this immutable sequence with respect to the
+operator innum. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
The rest of the collection without its first element.
The rest of the collection without its first element.
Attributes
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Iterates over the tails of this immutable sequence. The first value will be this immutable sequence and the final one will be an empty immutable sequence, with the intervening values the results of successive applications of tail.
Iterates over the tails of this immutable sequence. The first value will be this immutable sequence and the final one will be an empty immutable sequence, with the intervening values the results of successive applications of tail.
Attributes
- Returns
-
an iterator over all the tails of this immutable sequence
- Example
-
List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil) - Inherited from:
- IterableOps
- Source
- Iterable.scala
Given a collection factory factory, converts this immutable sequence to the appropriate representation for the current element type A. Example uses:
Given a collection factory factory, converts this immutable sequence to the appropriate representation for the current element type A. Example uses:
import scala.collection.mutable.ArrayBuffer
import scala.collection.immutable.BitSet
val xs: Iterable[Int] = Seq(1, 2, 3, 4, 5)
xs.to(List)
xs.to(ArrayBuffer)
xs.to(BitSet) // for xs: Iterable[Int]
Type parameters
- C1
-
the target collection type
Value parameters
- factory
-
the factory for the target collection type
Attributes
- Returns
-
a new collection of type
C1containing all elements of this immutable sequence - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Converts this immutable sequence to a Buffer.
Converts this immutable sequence to a Buffer.
Type parameters
- B
-
The type of elements of the result, a supertype of
A.
Attributes
- Returns
-
This immutable sequence as a
Buffer[B]. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Converts this immutable sequence to a Map, given an implicit coercion from the immutable sequence's type to a key-value tuple.
Converts this immutable sequence to a Map, given an implicit coercion from the immutable sequence's type to a key-value tuple.
Type parameters
- K
-
The key type for the resulting map.
- V
-
The value type for the resulting map.
Value parameters
- ev
-
an implicit evidence that
Ais a subtype of(K, V)
Attributes
- Returns
-
This immutable sequence as a
Map[K, V]. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Converts this immutable sequence to a Set.
Converts this immutable sequence to a Set.
Type parameters
- B
-
The type of elements of the result, a supertype of
A.
Attributes
- Returns
-
This immutable sequence as a
Set[B]. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Transposes this immutable sequence of iterable collections into a immutable sequence of immutable sequences.
Transposes this immutable sequence of iterable collections into a immutable sequence of immutable sequences.
The resulting collection's type will be guided by the static type of immutable sequence. 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))
Note: Even when applied to a view or a lazy collection it will always force the elements.
Type parameters
- B
-
the type of the elements of each iterable collection.
Value parameters
- asIterable
-
an implicit conversion which asserts that the element type of this immutable sequence is an
Iterable.
Attributes
- Returns
-
a two-dimensional immutable sequence of immutable sequences which has as nth row the nth column of this immutable sequence.
- Throws
-
IllegalArgumentException
if all collections in this immutable sequence are not of the same size.
- Inherited from:
- IterableOps
- Source
- Iterable.scala
Tries to extract a B from an A in a pattern matching expression.
Tries to extract a B from an A in a pattern matching expression.
Attributes
- Inherited from:
- PartialFunction
- Source
- PartialFunction.scala
Creates a non-strict filter of this immutable sequence.
Creates a non-strict filter of this immutable sequence.
Note: the difference between c filter p and c withFilter p is that the former creates a new collection, whereas the latter only restricts the domain of subsequent map, flatMap, foreach, and withFilter operations.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
an object of class
WithFilter, which supportsmap,flatMap,foreach, andwithFilteroperations. All these operations apply to those elements of this immutable sequence which satisfy the predicatep. - Inherited from:
- IterableOps
- Source
- Iterable.scala
Returns a immutable sequence formed from this immutable sequence and another iterable collection by combining corresponding elements in pairs. If one of the two collections is shorter than the other, placeholder elements are used to extend the shorter collection to the length of the longer.
Returns a immutable sequence formed from this immutable sequence and another iterable collection by combining corresponding elements in pairs. If one of the two collections is shorter than the other, placeholder elements are used to extend the shorter collection to the length of the longer.
Type parameters
- A1
-
the type of the first element in each result pair (supertype of
A) - B
-
the type of the second element in each result pair
Value parameters
- that
-
the iterable providing the second half of each result pair
- thatElem
-
the element to be used to fill up the result if
thatis shorter than this immutable sequence. - thisElem
-
the element to be used to fill up the result if this immutable sequence is shorter than
that.
Attributes
- Returns
-
a new immutable sequence containing pairs consisting of corresponding elements of this immutable sequence and
that. The length of the returned collection is the maximum of the lengths of this immutable sequence andthat. If this immutable sequence is shorter thanthat,thisElemvalues are used to pad the result. Ifthatis shorter than this immutable sequence,thatElemvalues are used to pad the result. - Inherited from:
- IterableOps
- Source
- Iterable.scala
Inherited and Abstract methods
Gets the element at the specified index. This operation is provided for convenience in Seq. It should not be assumed to be efficient unless you have an IndexedSeq.
Gets the element at the specified index. This operation is provided for convenience in Seq. It should not be assumed to be efficient unless you have an IndexedSeq.
Value parameters
- i
-
the index of the element to retrieve, zero-based
Attributes
- Inherited from:
- SeqOps
- Source
- Seq.scala
Deprecated and Inherited methods
Attributes
- Deprecated
-
[Since version 2.13.0]Use foldLeft instead of /: - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Use foldRight instead of :\\ - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Aggregates the results of applying an operator to subsequent elements.
Aggregates the results of applying an operator to subsequent elements.
Since this method degenerates to foldLeft for sequential (non-parallel) collections, where the combining operation is ignored, it is advisable to prefer foldLeft for that case.
For parallel collections, use the aggregate method specified by scala.collection.parallel.ParIterableLike.
Type parameters
- B
-
the result type, produced by
seqop,combop, and by this function as a final result.
Value parameters
- combop
-
an associative operator for combining sequential results, unused for sequential collections.
- seqop
-
the binary operator used to accumulate the result.
- z
-
the start value, a neutral element for
seqop.
Attributes
- Deprecated
-
[Since version 2.13.0]For sequential collections, prefer `foldLeft(z)(seqop)`. For parallel collections, use `ParIterableLike#aggregate`. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Use iterableFactory instead - Inherited from:
- IterableOps
- Source
- Iterable.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Use `dest ++= coll` instead - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Tests whether this immutable sequence is known to have a finite size. All strict collections are known to have finite size. For a non-strict collection such as Stream, the predicate returns **true** if all elements have been computed. It returns **false** if the stream is not yet evaluated to the end. Non-empty Iterators usually return **false** even if they were created from a collection with a known finite size.
Tests whether this immutable sequence is known to have a finite size. All strict collections are known to have finite size. For a non-strict collection such as Stream, the predicate returns **true** if all elements have been computed. It returns **false** if the stream is not yet evaluated to the end. Non-empty Iterators usually return **false** even if they were created from a collection with a known finite size.
Note: many collection methods will not work on collections of infinite sizes. The typical failure mode is an infinite loop. These methods always attempt a traversal without checking first that hasDefiniteSize returns **true**. However, checking hasDefiniteSize can provide an assurance that size is well-defined and non-termination is not a concern.
Attributes
- Returns
-
**true**if this collection is known to have finite size,**false**otherwise. - See also
-
method
knownSizefor a more useful alternative - Deprecated
-
[Since version 2.13.0]Check .knownSize instead of .hasDefiniteSize for more actionable information (see scaladoc for details)This method is deprecated in 2.13 because it does not provide any actionable information. As noted above, even the collection library itself does not use it. When there is no guarantee that a collection is finite, it is generally best to attempt a computation anyway and document that it will not terminate for infinite collections rather than backing out because this would prevent performing the computation on collections that are in fact finite even though
hasDefiniteSizereturnsfalse. - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Returns the length of the longest prefix whose elements all satisfy some predicate.
Returns the length of the longest prefix whose elements all satisfy some predicate.
Note: may not terminate for infinite-sized collections.
Value parameters
- p
-
the predicate used to test elements.
Attributes
- Returns
-
the length of the longest prefix of this immutable sequence such that every element of the segment satisfies the predicate
p. - Deprecated
-
[Since version 2.13.0]Use segmentLength instead of prefixLength - Inherited from:
- SeqOps
- Source
- Seq.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Use coll instead of repr in a collection implementation, use the collection value itself from the outside - Inherited from:
- IterableOps
- Source
- Iterable.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Iterable.seq always returns the iterable itself - Inherited from:
- Iterable
- Source
- Iterable.scala
Attributes
- Returns
-
This collection as an
Iterable[A]. No new collection will be built ifthisis already anIterable[A]. - Deprecated
-
[Since version 2.13.7]toIterable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn\'t copy non-immutable collections - Inherited from:
- Iterable
- Source
- Iterable.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Use .iterator instead of .toIterator - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Attributes
- Deprecated
-
[Since version 2.13.0]Use .to(LazyList) instead of .toStream - Inherited from:
- IterableOnceOps
- Source
- IterableOnce.scala
Converts this immutable sequence to an unspecified Iterable. Will return the same collection if this instance is already Iterable.
Converts this immutable sequence to an unspecified Iterable. Will return the same collection if this instance is already Iterable.
Attributes
- Returns
-
An Iterable containing all elements of this immutable sequence.
- Deprecated
-
[Since version 2.13.0]toTraversable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn\'t copy non-immutable collections - Inherited from:
- IterableOps
- Source
- Iterable.scala
Produces a new sequence which contains all elements of this immutable sequence and also all elements of a given sequence. xs union ys is equivalent to xs ++ ys.
Produces a new sequence which contains all elements of this immutable sequence and also all elements of a given sequence. xs union ys is equivalent to xs ++ ys.
Type parameters
- B
-
the element type of the returned immutable sequence.
Value parameters
- that
-
the sequence to add.
Attributes
- Returns
-
a new collection which contains all elements of this immutable sequence followed by all elements of
that. - Deprecated
-
[Since version 2.13.0]Use `concat` instead - Inherited from:
- SeqOps
- Source
- Seq.scala