IterableDecorator

scala.collection.decorators.IterableDecorator
class IterableDecorator[C, I <: IsIterable[C]](coll: C)(implicit val it: I)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def foldSomeLeft[B](z: B)(op: (B, A) => Option[B]): B

Left to right fold that stops if the combination function op returns None

Left to right fold that stops if the combination function op returns None

Attributes

B

the result type of the binary operator

op

the binary operator

z

the start value

Returns:

the result of inserting op between consecutive elements of the collection, going left to right with the start value z on the left, and stopping when all the elements have been traversed or earlier if the operator returns None

def lazyFoldLeft[B](z: B)(op: (B, => A) => B): B

Lazy left to right fold. Like foldLeft but the combination function op is non-strict in its second parameter. If op(b, a) chooses not to evaluate a and returns b, this terminates the traversal early.

Lazy left to right fold. Like foldLeft but the combination function op is non-strict in its second parameter. If op(b, a) chooses not to evaluate a and returns b, this terminates the traversal early.

Attributes

B

the result type of the binary operator

op

the binary operator

z

the start value

Returns:

the result of inserting op between consecutive elements of the collection, going left to right with the start value z on the left, and stopping when all the elements have been traversed or earlier if op(b, a) choose not to evaluate a and returns b

def lazyFoldRight[B](z: B)(op: A => Either[B, B => B]): B

Right to left fold that can be interrupted before traversing the whole collection.

Right to left fold that can be interrupted before traversing the whole collection.

Attributes

B

the result type

op

the operator

z

the start value

Returns:

the result of applying the operator between consecutive elements of the collection, going right to left, with the start value z on the right. The result of the application of the function op to each element drives the process: if it returns Left(result), then result is returned without iterating further; if it returns Right(f), the function f is applied to the previous result to produce the new result and the fold continues.

def splitBy[K, CC1, CC2](f: A => K)(implicit bf: BuildFrom[C, A, CC1], bff: BuildFrom[C, CC1, CC2]): CC2

Constructs a collection where consecutive elements are accumulated as long as the output of f for each element doesn't change.

Constructs a collection where consecutive elements are accumulated as long as the output of f for each element doesn't change.

Vector(1,2,2,3,3,3,2,2)
.splitBy(identity)

produces

Vector(Vector(1),
Vector(2,2),
Vector(3,3,3),
Vector(2,2))

Attributes

K

the type of the computed key

f

the function to compute a key for an element

Returns:

a collection of collections of the consecutive elements with the same key in the original collection

Implicits

Implicits

implicit val it: I