NonEmptyChunk

zio.blocks.chunk.NonEmptyChunk
See theNonEmptyChunk companion object
final class NonEmptyChunk[+A] extends Serializable

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
trait Serializable
class Object
trait Matchable
class Any
Self type

Members list

Value members

Abstract methods

Implicitly added by toChunk

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

def &(that: Chunk[Boolean])(implicit ev: A <:< Boolean): BitChunkByte
Implicitly added by toChunk

Returns the bitwise AND of this chunk and the specified chunk.

Returns the bitwise AND of this chunk and the specified chunk.

Attributes

Source
Chunk.scala
final def ++[A1 >: A](that: Chunk[A1]): Chunk[A1]
Implicitly added by toChunk

Returns the concatenation of this chunk with the specified chunk.

Returns the concatenation of this chunk with the specified chunk.

Attributes

Source
Chunk.scala
final def ++[A1 >: A](that: NonEmptyChunk[A1]): NonEmptyChunk[A1]
Implicitly added by toChunk

Returns the concatenation of this chunk with the specified chunk.

Returns the concatenation of this chunk with the specified chunk.

Attributes

Source
Chunk.scala
def ++[A1 >: A](that: Chunk[A1]): NonEmptyChunk[A1]

Appends the specified Chunk to the end of this NonEmptyChunk.

Appends the specified Chunk to the end of this NonEmptyChunk.

Attributes

Source
Chunk.scala
def +:[A1 >: A](a: A1): NonEmptyChunk[A1]

A symbolic alias for prepended.

A symbolic alias for prepended.

Attributes

Source
Chunk.scala
def :+[A1 >: A](a: A1): NonEmptyChunk[A1]

A symbolic alias for appended.

A symbolic alias for appended.

Attributes

Source
Chunk.scala
def ^(that: Chunk[Boolean])(implicit ev: A <:< Boolean): BitChunkByte
Implicitly added by toChunk

Returns the bitwise XOR of this chunk and the specified chunk.

Returns the bitwise XOR of this chunk and the specified chunk.

Attributes

Source
Chunk.scala
def appended[A1 >: A](a: A1): NonEmptyChunk[A1]

Appends a single element to the end of this NonEmptyChunk.

Appends a single element to the end of this NonEmptyChunk.

Attributes

Source
Chunk.scala
def asBase64String(implicit ev: IsText[A]): String
Implicitly added by toChunk

Creates a base64 encoded string based on the chunk's data.

Creates a base64 encoded string based on the chunk's data.

Attributes

Source
Chunk.scala
def asBits(implicit ev: A <:< Byte): NonEmptyChunk[Boolean]

Converts this NonEmptyChunk of bytes to a NonEmptyChunk of bits.

Converts this NonEmptyChunk of bytes to a NonEmptyChunk of bits.

Attributes

Source
Chunk.scala
final def asBitsByte(implicit ev: A <:< Byte): Chunk[Boolean]
Implicitly added by toChunk

Converts a chunk of bytes to a chunk of bits.

Converts a chunk of bytes to a chunk of bits.

Attributes

Source
Chunk.scala
final def asBitsInt(endianness: Endianness)(implicit ev: A <:< Int): Chunk[Boolean]
Implicitly added by toChunk

Converts a chunk of ints to a chunk of bits.

Converts a chunk of ints to a chunk of bits.

Attributes

Source
Chunk.scala
def asBitsInt(endianness: Endianness)(implicit ev: A <:< Int): NonEmptyChunk[Boolean]

Converts this NonEmptyChunk of ints to a NonEmptyChunk of bits.

Converts this NonEmptyChunk of ints to a NonEmptyChunk of bits.

Attributes

Source
Chunk.scala
final def asBitsLong(endianness: Endianness)(implicit ev: A <:< Long): Chunk[Boolean]
Implicitly added by toChunk

Converts a chunk of longs to a chunk of bits.

Converts a chunk of longs to a chunk of bits.

Attributes

Source
Chunk.scala
def asBitsLong(endianness: Endianness)(implicit ev: A <:< Long): NonEmptyChunk[Boolean]

Converts this NonEmptyChunk of longs to a NonEmptyChunk of bits.

Converts this NonEmptyChunk of longs to a NonEmptyChunk of bits.

Attributes

Source
Chunk.scala
final def asString(implicit ev: IsText[A]): String
Implicitly added by toChunk

Creates a new String based on this chunk's data.

Creates a new String based on this chunk's data.

Attributes

Source
Chunk.scala
final def asString(charset: Charset)(implicit ev: A <:< Byte): String
Implicitly added by toChunk

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
def boolean(index: Int)(implicit ev: A <:< Boolean): Boolean
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def byte(index: Int)(implicit ev: A <:< Byte): Byte
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def char(index: Int)(implicit ev: A <:< Char): Char
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def collect[B](pf: PartialFunction[A, B]): Chunk[B]

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
def collectFirst[B](pf: PartialFunction[A, B]): Option[B]

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
def collectWhile[B](pf: PartialFunction[A, B]): Chunk[B]
Implicitly added by toChunk

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
final def corresponds[B](that: Chunk[B])(f: (A, B) => Boolean): Boolean
Implicitly added by toChunk

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
def dedupe: Chunk[A]
Implicitly added by toChunk

Deduplicates adjacent elements that are identical.

Deduplicates adjacent elements that are identical.

Attributes

Source
Chunk.scala

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
def double(index: Int)(implicit ev: A <:< Double): Double
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def dropUntil(f: A => Boolean): Chunk[A]
Implicitly added by toChunk

Drops all elements until the predicate returns true.

Drops all elements until the predicate returns true.

Attributes

Source
Chunk.scala
override def equals(that: Any): Boolean

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
def exists(p: A => Boolean): Boolean

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
def filter(p: A => Boolean): Chunk[A]

Filters the elements of this chunk based on the predicate provided.

Filters the elements of this chunk based on the predicate provided.

Attributes

Source
Chunk.scala
def filterNot(p: A => Boolean): Chunk[A]

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
def find(p: A => Boolean): Option[A]

Searches for the first element that satisfies the given predicate p.

Searches for the first element that satisfies the given predicate p.

Attributes

Source
Chunk.scala
def flatMap[B](f: A => NonEmptyChunk[B]): NonEmptyChunk[B]

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
def flatten[B](implicit ev: A <:< NonEmptyChunk[B]): NonEmptyChunk[B]

Flattens a NonEmptyChunk of NonEmptyChunk values to a single NonEmptyChunk.

Flattens a NonEmptyChunk of NonEmptyChunk values to a single NonEmptyChunk.

Attributes

Source
Chunk.scala
def float(index: Int)(implicit ev: A <:< Float): Float
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def foldLeft[B](z: B)(op: (B, A) => B): B

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
final def foldWhile[S](s0: S)(pred: S => Boolean)(f: (S, A) => S): S
Implicitly added by toChunk

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
def forall(p: A => Boolean): Boolean

Tests whether a predicate holds for all elements in the chunk.

Tests whether a predicate holds for all elements in the chunk.

Attributes

Source
Chunk.scala
def groupBy[K](f: A => K): Map[K, NonEmptyChunk[A]]

Groups the values in this NonEmptyChunk using the specified function.

Groups the values in this NonEmptyChunk using the specified function.

Attributes

Source
Chunk.scala
def groupMap[K, V](key: A => K)(f: A => V): Map[K, NonEmptyChunk[V]]

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
def grouped(size: Int): Iterator[NonEmptyChunk[A]]

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
override def hashCode: Int

Returns the hashcode of this NonEmptyChunk.

Returns the hashcode of this NonEmptyChunk.

Attributes

Definition Classes
Any
Source
Chunk.scala
def head: A

Retrieves the first element of the collection chunk.

Retrieves the first element of the collection chunk.

Attributes

Source
Chunk.scala
def init: Chunk[A]

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
def int(index: Int)(implicit ev: A <:< Int): Int
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def iterator: Iterator[A]

Provides an iterator to traverse through the elements of the chunk.

Provides an iterator to traverse through the elements of the chunk.

Attributes

Source
Chunk.scala
def last: A

Retrieves the last element of a non-empty chunk.

Retrieves the last element of a non-empty chunk.

Attributes

Source
Chunk.scala
def long(index: Int)(implicit ev: A <:< Long): Long
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def map[B](f: A => B): NonEmptyChunk[B]

Transforms the elements of this NonEmptyChunk with the specified function.

Transforms the elements of this NonEmptyChunk with the specified function.

Attributes

Source
Chunk.scala
final def mapAccum[S, B](s0: S)(f: (S, A) => (S, B)): (S, Chunk[B])
Implicitly added by toChunk

Statefully maps over the chunk, producing new elements of type B.

Statefully maps over the chunk, producing new elements of type B.

Attributes

Source
Chunk.scala
def mapAccum[S, B](s: S)(f: (S, A) => (S, B)): (S, NonEmptyChunk[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
def materialize[A1 >: A]: Chunk[A1]
Implicitly added by toChunk

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
def materialize[A1 >: A]: NonEmptyChunk[A1]

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
def negate(implicit ev: A <:< Boolean): BitChunkByte
Implicitly added by toChunk

Returns the bitwise NOT of this chunk.

Returns the bitwise NOT of this chunk.

Attributes

Source
Chunk.scala
def nonEmptyOrElse[B](ifEmpty: => B)(fn: NonEmptyChunk[A] => B): B
Implicitly added by toChunk

Runs fn if a chunk is not empty or returns the default value.

Runs fn if a chunk is not empty or returns the default value.

Attributes

Source
Chunk.scala
def prepended[A1 >: A](a: A1): NonEmptyChunk[A1]

Prepends a single element to the beginning of this NonEmptyChunk.

Prepends a single element to the beginning of this NonEmptyChunk.

Attributes

Source
Chunk.scala
def reduce[B >: A](op: (B, B) => B): B

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
def reduceMapLeft[B](map: A => B)(reduce: (B, A) => B): B

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
def reduceMapRight[B](map: A => B)(reduce: (A, B) => B): B

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
def short(index: Int)(implicit ev: A <:< Short): Short
Implicitly added by toChunk

Get the element at the specified index.

Get the element at the specified index.

Attributes

Source
Chunk.scala
def size: Int

Returns the size of the chunk.

Returns the size of the chunk.

Attributes

Source
Chunk.scala
def sortBy[B](f: A => B)(implicit ord: Ordering[B]): NonEmptyChunk[A]

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
def sorted[B >: A](implicit ord: Ordering[B]): NonEmptyChunk[B]

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
final def split(n: Int): Chunk[Chunk[A]]
Implicitly added by toChunk

Splits this chunk into n equally sized chunks.

Splits this chunk into n equally sized chunks.

Attributes

Source
Chunk.scala
final def splitWhere(f: A => Boolean): (Chunk[A], Chunk[A])
Implicitly added by toChunk

Splits this chunk on the first element that matches this predicate.

Splits this chunk on the first element that matches this predicate.

Attributes

Source
Chunk.scala
def tail: Chunk[A]

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
def toArray[B >: A : ClassTag]: Array[B]

Converts this NonEmptyChunk to an array.

Converts this NonEmptyChunk to an array.

Attributes

Source
Chunk.scala
final def toBinaryString(implicit ev: A <:< Boolean): String
Implicitly added by toChunk

Renders this chunk of bits as a binary string.

Renders this chunk of bits as a binary string.

Attributes

Source
Chunk.scala
def toChunk: Chunk[A]

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
def toCons[A1 >: A]: ::[A1]

Converts this NonEmptyChunk to the :: case of a List.

Converts this NonEmptyChunk to the :: case of a List.

Attributes

Source
Chunk.scala
def toIterable: Iterable[A]

Converts this NonEmptyChunk to an Iterable.

Converts this NonEmptyChunk to an Iterable.

Attributes

Source
Chunk.scala
def toList: List[A]

Converts this NonEmptyChunk to a List.

Converts this NonEmptyChunk to a List.

Attributes

Source
Chunk.scala
def toPackedByte(implicit ev: A <:< Boolean): Chunk[Byte]
Implicitly added by toChunk

Converts a chunk of Boolean values into a packed Byte representation.

Converts a chunk of Boolean values into a packed Byte representation.

Attributes

Source
Chunk.scala
def toPackedInt(endianness: Endianness)(implicit ev: A <:< Boolean): Chunk[Int]
Implicitly added by toChunk

Converts a chunk of Boolean values into a packed Int representation.

Converts a chunk of Boolean values into a packed Int representation.

Attributes

Source
Chunk.scala
def toPackedLong(endianness: Endianness)(implicit ev: A <:< Boolean): Chunk[Long]
Implicitly added by toChunk

Converts a chunk of Boolean values into a packed Long representation.

Converts a chunk of Boolean values into a packed Long representation.

Attributes

Source
Chunk.scala
override def toString: String

Renders this NonEmptyChunk as a String.

Renders this NonEmptyChunk as a String.

Attributes

Definition Classes
Any
Source
Chunk.scala
final def zip[B](that: Chunk[B]): Chunk[(A, B)]
Implicitly added by toChunk

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
def zip[B](that: NonEmptyChunk[B]): NonEmptyChunk[(A, B)]

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
final def zipAll[B](that: Chunk[B]): Chunk[(Option[A], Option[B])]
Implicitly added by toChunk

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
def zipAll[B](that: Chunk[B]): NonEmptyChunk[(Option[A], Option[B])]

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
final def zipAllWith[B, C](that: Chunk[B])(left: A => C, right: B => C)(both: (A, B) => C): Chunk[C]
Implicitly added by toChunk

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
def zipAllWith[B, C](that: Chunk[B])(left: A => C, right: B => C)(both: (A, B) => C): NonEmptyChunk[C]

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
final def zipWith[B, C](that: Chunk[B])(f: (A, B) => C): Chunk[C]
Implicitly added by toChunk

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
def zipWith[B, C](that: NonEmptyChunk[B])(f: (A, B) => C): NonEmptyChunk[C]

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
def zipWithIndex: NonEmptyChunk[(A, Int)]

Annotates each element of this NonEmptyChunk with its index.

Annotates each element of this NonEmptyChunk with its index.

Attributes

Source
Chunk.scala
final def zipWithIndexFrom(indexOffset: Int): Chunk[(A, Int)]
Implicitly added by toChunk

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
def zipWithIndexFrom(indexOffset: Int): NonEmptyChunk[(A, Int)]

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
def |(that: Chunk[Boolean])(implicit ev: A <:< Boolean): BitChunkByte
Implicitly added by toChunk

Returns the bitwise OR of this chunk and the specified chunk.

Returns the bitwise OR of this chunk and the specified chunk.

Attributes

Source
Chunk.scala

Inherited methods

final def ++[B >: A](suffix: IterableOnce[B]): Chunk[B]
Implicitly added by toChunk

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
final def +:[B >: A](elem: B): Chunk[B]
Implicitly added by toChunk

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 elem followed by all elements of this immutable sequence

Inherited from:
SeqOps
Source
Seq.scala
final def :+[B >: A](elem: B): Chunk[B]
Implicitly added by toChunk

Alias for appended.

Alias for appended.

Note that :-ending operators are right associative (see example). A mnemonic for +: vs. :+ is: the COLon goes on the COLlection side.

Attributes

Inherited from:
SeqOps
Source
Seq.scala
def :++[B >: A](suffix: IterableOnce[B]): Chunk[B]
Implicitly added by toChunk

Alias for appendedAll.

Alias for appendedAll.

Attributes

Inherited from:
SeqOps
Source
Seq.scala
final def addString(b: StringBuilder): b.type
Implicitly added by toChunk

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 b to which elements were appended.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def addString(b: StringBuilder, sep: String): b.type
Implicitly added by toChunk

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 b to which elements were appended.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def addString(b: StringBuilder, start: String, sep: String, end: String): b.type
Implicitly added by toChunk

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 b to which elements were appended.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def andThen[C](k: PartialFunction[A, C]): PartialFunction[Int, C]
Implicitly added by toChunk

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 x to k(this(x)).

Inherited from:
PartialFunction
Source
PartialFunction.scala
def applyOrElse[A1 <: Int, B1 >: A](x: A1, default: A1 => B1): B1
Implicitly added by toChunk

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/andThen chains does not lead to excessive apply/isDefinedAt evaluation
  • lift and unlift do not evaluate source functions twice on each invocation
  • runWith allows 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
def collectFirst[B](pf: PartialFunction[A, B]): Option[B]
Implicitly added by toChunk

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 None if none exists.

Example

Seq("a", 1, 5L).collectFirst { case x: Int => x*10 } = Some(10)

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def combinations(n: Int): Iterator[Chunk[A]]
Implicitly added by toChunk

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
def compose[R](k: PartialFunction[R, Int]): PartialFunction[R, A]
Implicitly added by toChunk

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 x to this(k(x)).

Inherited from:
PartialFunction
Source
PartialFunction.scala
def compose[A](g: A => Int): A => A
Implicitly added by toChunk

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 g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
Source
Function1.scala
def contains[A1 >: A](elem: A1): Boolean
Implicitly added by toChunk

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

true if this immutable sequence has an element that is equal (as determined by ==) to elem, false otherwise.

Inherited from:
SeqOps
Source
Seq.scala
def containsSlice[B >: A](that: Seq[B]): Boolean
Implicitly added by toChunk

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

true if this immutable sequence contains a slice with the same elements as that, otherwise false.

Inherited from:
SeqOps
Source
Seq.scala
def copyToArray[B >: A](dest: Array[B], start: Int): Int
Implicitly added by toChunk

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
def copyToArray[B >: A](dest: Array[B]): Int
Implicitly added by toChunk

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
def corresponds[B](that: IterableOnce[B])(p: (A, B) => Boolean): Boolean
Implicitly added by toChunk

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

true if both collections have the same length and p(x, y) is true for all corresponding elements x of this iterator and y of that, otherwise false

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def corresponds[B](that: Seq[B])(p: (A, B) => Boolean): Boolean
Implicitly added by toChunk

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

true if both sequences have the same length and p(x, y) is true for all corresponding elements x of this immutable sequence and y of that, otherwise false.

Inherited from:
SeqOps
Source
Seq.scala
def count(p: A => Boolean): Int
Implicitly added by toChunk

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
def distinct: Chunk[A]
Implicitly added by toChunk

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
def elementWise: ElementWiseExtractor[Int, A]
Implicitly added by toChunk

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
def endsWith[B >: A](that: Iterable[B]): Boolean
Implicitly added by toChunk

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

true if this immutable sequence has that as a suffix, false otherwise.

Inherited from:
SeqOps
Source
Seq.scala
def findLast(p: A => Boolean): Option[A]
Implicitly added by toChunk

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, or None if none exists.

Inherited from:
SeqOps
Source
Seq.scala
def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1
Implicitly added by toChunk

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 op for the result to always be the same across runs.

Attributes

Returns

The result of applying op between all the elements and z, or z if this immutable sequence is empty.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def foreach[U](f: A => U): Unit
Implicitly added by toChunk

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
protected def fromSpecific(coll: IterableOnce[A]): Chunk[A]
Implicitly added by toChunk

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 C containing the elements of coll

Note

When implementing a custom collection type and refining C to the new type, this method needs to be overridden (the compiler will issue an error otherwise). In the common case where C =:= CC[A], this can be done by mixing in the scala.collection.IterableFactoryDefaults trait, which implements the method using iterableFactory.

As witnessed by the @uncheckedVariance annotation, using this method might be unsound. However, as long as it is called with an Iterable[A] obtained from this collection (as it is the case in the implementations of operations where we use a View[A]), it is safe.

Inherited from:
IterableFactoryDefaults
Source
Iterable.scala
def groupBy[K](f: A => K): Map[K, Chunk[A]]
Implicitly added by toChunk

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
def groupMap[K, B](key: A => K)(f: A => B): Map[K, Chunk[B]]
Implicitly added by toChunk

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 k produced by key with a immutable sequence of values produced by applying f to elements that map to k

Inherited from:
IterableOps
Source
Iterable.scala
def groupMapReduce[K, B](key: A => K)(f: A => B)(reduce: (B, B) => B): Map[K, B]
Implicitly added by toChunk

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
def grouped(size: Int): Iterator[Chunk[A]]
Implicitly added by toChunk

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 size size if the elements don't divide evenly.

See also

scala.collection.Iterator, method grouped

Inherited from:
IterableOps
Source
Iterable.scala
def indexOf[B >: A](elem: B): Int
Implicitly added by toChunk

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 >= 0 of the first element of this immutable sequence that is equal (as determined by ==) to elem, or -1, if none exists.

Inherited from:
SeqOps
Source
Seq.scala
def indexOf[B >: A](elem: B, from: Int): Int
Implicitly added by toChunk

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 >= from of the first element of this immutable sequence that is equal (as determined by ==) to elem, or -1, if none exists.

Inherited from:
SeqOps
Source
Seq.scala
def indexOfSlice[B >: A](that: Seq[B]): Int
Implicitly added by toChunk

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 >= 0 such that the elements of this immutable sequence starting at this index match the elements of sequence that, or -1 if no such subsequence exists.

Inherited from:
SeqOps
Source
Seq.scala
def indexOfSlice[B >: A](that: Seq[B], from: Int): Int
Implicitly added by toChunk

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 >= from such that the elements of this immutable sequence starting at this index match the elements of sequence that, or -1 if no such subsequence exists.

Inherited from:
SeqOps
Source
Seq.scala
def indexWhere(p: A => Boolean): Int
Implicitly added by toChunk

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 >= 0 of the first element of this immutable sequence that satisfies the predicate p, or -1, if none exists.

Inherited from:
SeqOps
Source
Seq.scala
def indices: Range
Implicitly added by toChunk

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 Range value from 0 to one less than the length of this immutable sequence.

Inherited from:
SeqOps
Source
Seq.scala
def init: Chunk[A]
Implicitly added by toChunk

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
def inits: Iterator[Chunk[A]]
Implicitly added by toChunk

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
def isDefinedAt(idx: Int): Boolean
Implicitly added by toChunk

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

true if this immutable sequence contains an element at position idx, false otherwise.

Inherited from:
SeqOps
Source
Seq.scala
def iterator: Iterator[A]
Implicitly added by toChunk

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
def lastIndexOf[B >: A](elem: B, end: Int = ...): Int
Implicitly added by toChunk

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 &lt;= end of the last element of this immutable sequence that is equal (as determined by ==) to elem, or -1, if none exists.

Inherited from:
SeqOps
Source
Seq.scala
def lastIndexOfSlice[B >: A](that: Seq[B]): Int
Implicitly added by toChunk

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 -1 if no such subsequence exists.

Inherited from:
SeqOps
Source
Seq.scala
def lastIndexOfSlice[B >: A](that: Seq[B], end: Int): Int
Implicitly added by toChunk

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 &lt;= end such that the elements of this immutable sequence starting at this index match the elements of sequence that, or -1 if no such subsequence exists.

Inherited from:
SeqOps
Source
Seq.scala
def lastIndexWhere(p: A => Boolean): Int
Implicitly added by toChunk

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
def lastIndexWhere(p: A => Boolean, end: Int): Int
Implicitly added by toChunk

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 &lt;= end of the last element of this immutable sequence that satisfies the predicate p, or -1, if none exists.

Inherited from:
SeqOps
Source
Seq.scala
def lazyZip[B](that: Iterable[B]): LazyZip2[A, B, this.type]
Implicitly added by toChunk

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 LazyZip2 that allows strict operations to be performed on the lazily evaluated pairs or chained calls to lazyZip. Implicit conversion to Iterable[(A, B)] is also supported.

Inherited from:
Iterable
Source
Iterable.scala
final def lengthIs: SizeCompareOps
Implicitly added by toChunk

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
def lift: Int => Option[A]
Implicitly added by toChunk

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 x to Some(this(x)) if this is defined for x, and to None otherwise.

See also

Function.unlift

Inherited from:
PartialFunction
Source
PartialFunction.scala
def max[B >: A](implicit ord: Ordering[B]): A
Implicitly added by toChunk

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
def maxBy[B](f: A => B)(implicit ord: Ordering[B]): A
Implicitly added by toChunk

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 f with respect to the ordering ord.

Throws
UnsupportedOperationException

if this immutable sequence is empty.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def maxByOption[B](f: A => B)(implicit ord: Ordering[B]): Option[A]
Implicitly added by toChunk

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 f with respect to the ordering ord.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def maxOption[B >: A](implicit ord: Ordering[B]): Option[A]
Implicitly added by toChunk

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
def min[B >: A](implicit ord: Ordering[B]): A
Implicitly added by toChunk

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
def minBy[B](f: A => B)(implicit ord: Ordering[B]): A
Implicitly added by toChunk

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 f with respect to the ordering ord.

Throws
UnsupportedOperationException

if this immutable sequence is empty.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def minByOption[B](f: A => B)(implicit ord: Ordering[B]): Option[A]
Implicitly added by toChunk

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 f with respect to the ordering ord.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def minOption[B >: A](implicit ord: Ordering[B]): Option[A]
Implicitly added by toChunk

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
final def mkString: String
Implicitly added by toChunk

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
final def mkString(sep: String): String
Implicitly added by toChunk

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 string sep.

Example

List(1, 2, 3).mkString("|") = "1|2|3"

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def mkString(start: String, sep: String, end: String): String
Implicitly added by toChunk

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 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

List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
protected def newSpecificBuilder: Builder[A, Chunk[A]]
Implicitly added by toChunk

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 Builder will break laziness. As a consequence, operations should preferably be implemented with fromSpecific instead of this method.

Note

When implementing a custom collection type and refining C to the new type, this method needs to be overridden (the compiler will issue an error otherwise). In the common case where C =:= CC[A], this can be done by mixing in the scala.collection.IterableFactoryDefaults trait, which implements the method using iterableFactory.

As witnessed by the @uncheckedVariance annotation, using this method might be unsound. However, as long as the returned builder is only fed with A values taken from this instance, it is safe.

Inherited from:
IterableFactoryDefaults
Source
Iterable.scala
def nonEmpty: Boolean
Implicitly added by toChunk

Tests whether the immutable sequence is not empty.

Tests whether the immutable sequence is not empty.

Attributes

Returns

true if the immutable sequence contains at least one element, false otherwise.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def orElse[A1 <: Int, B1 >: A](that: PartialFunction[A1, B1]): PartialFunction[A1, B1]
Implicitly added by toChunk

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 takes x to this(x) where this is defined, and to that(x) where it is not.

Inherited from:
PartialFunction
Source
PartialFunction.scala
def permutations: Iterator[Chunk[A]]
Implicitly added by toChunk

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
def product[B >: A](implicit num: Numeric[B]): B
Implicitly added by toChunk

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 in num.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def reduce[B >: A](op: (B, B) => B): B
Implicitly added by toChunk

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 op between all the elements if the immutable sequence is nonempty.

Throws
UnsupportedOperationException

if this immutable sequence is empty.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def reduceLeft[B >: A](op: (B, A) => B): B
Implicitly added by toChunk

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 op to all elements of this immutable sequence, going left to right.

Throws
UnsupportedOperationException

if this immutable sequence is empty.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def reduceLeftOption[B >: A](op: (B, A) => B): Option[B]
Implicitly added by toChunk

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 op going left to right if the immutable sequence is nonempty, inside a Some, and None otherwise.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def reduceOption[B >: A](op: (B, B) => B): Option[B]
Implicitly added by toChunk

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 op if the immutable sequence is nonempty, inside a Some, and None otherwise.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def reduceRight[B >: A](op: (A, B) => B): B
Implicitly added by toChunk

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 op to all elements of this immutable sequence, going right to left.

Throws
UnsupportedOperationException

if this immutable sequence is empty.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def reduceRightOption[B >: A](op: (A, B) => B): Option[B]
Implicitly added by toChunk

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 op going right to left if the immutable sequence is nonempty, inside a Some, and None otherwise.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def runWith[U](action: A => U): Int => Boolean
Implicitly added by toChunk

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
def scan[B >: A](z: B)(op: (B, B) => B): Chunk[B]
Implicitly added by toChunk

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
def scanRight[B](z: B)(op: (A, B) => B): Chunk[B]
Implicitly added by toChunk

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
def segmentLength(p: A => Boolean, from: Int): Int
Implicitly added by toChunk

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 from such that every element of the segment satisfies the predicate p.

Inherited from:
SeqOps
Source
Seq.scala
final def segmentLength(p: A => Boolean): Int
Implicitly added by toChunk

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
final def sizeIs: SizeCompareOps
Implicitly added by toChunk

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
def sliding(size: Int): Iterator[Chunk[A]]
Implicitly added by toChunk

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 than size elements, 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 iterator

List(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
def sortBy[B](f: A => B)(implicit ord: Ordering[B]): Chunk[A]
Implicitly added by toChunk

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 ordering ord is 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 &lt; y if ord.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
def sortWith(lt: (A, A) => Boolean): Chunk[A]
Implicitly added by toChunk

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
def startsWith[B >: A](that: IterableOnce[B], offset: Int = ...): Boolean
Implicitly added by toChunk

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

true if the sequence that is contained in this immutable sequence at index offset, otherwise false.

Inherited from:
SeqOps
Source
Seq.scala
final protected def strictOptimizedCollect[B, C2](b: Builder[B, C2], pf: PartialFunction[A, B]): C2
Implicitly added by toChunk

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
final protected def strictOptimizedConcat[B >: A, C2](that: IterableOnce[B], b: Builder[B, C2]): C2
Implicitly added by toChunk

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
final protected def strictOptimizedFlatMap[B, C2](b: Builder[B, C2], f: A => IterableOnce[B]): C2
Implicitly added by toChunk

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
final protected def strictOptimizedFlatten[B, C2](b: Builder[B, C2])(implicit toIterableOnce: A => IterableOnce[B]): C2
Implicitly added by toChunk

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 A can be seen as an IterableOnce[B]

Attributes

Returns

The resulting collection

Inherited from:
StrictOptimizedIterableOps
Source
StrictOptimizedIterableOps.scala
final protected def strictOptimizedMap[B, C2](b: Builder[B, C2], f: A => B): C2
Implicitly added by toChunk

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
final protected def strictOptimizedZip[B, C2](that: IterableOnce[B], b: Builder[(A, B), C2]): C2
Implicitly added by toChunk

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
def sum[B >: A](implicit num: Numeric[B]): B
Implicitly added by toChunk

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 in num.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def tail: Chunk[A]
Implicitly added by toChunk

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
def tails: Iterator[Chunk[A]]
Implicitly added by toChunk

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
def to[C1](factory: Factory[A, C1]): C1
Implicitly added by toChunk

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 C1 containing all elements of this immutable sequence

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def toBuffer[B >: A]: Buffer[B]
Implicitly added by toChunk

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
def toMap[K, V](implicit ev: A <:< (K, V)): Map[K, V]
Implicitly added by toChunk

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 A is a subtype of (K, V)

Attributes

Returns

This immutable sequence as a Map[K, V].

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def toSet[B >: A]: Set[B]
Implicitly added by toChunk

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
def transpose[B](implicit asIterable: A => Iterable[B]): Chunk[Chunk[B]]
Implicitly added by toChunk

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
def unapply(a: Int): Option[A]
Implicitly added by toChunk

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
def withFilter(p: A => Boolean): WithFilter[A, Chunk]
Implicitly added by toChunk

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 supports map, flatMap, foreach, and withFilter operations. All these operations apply to those elements of this immutable sequence which satisfy the predicate p.

Inherited from:
IterableOps
Source
Iterable.scala
def zipAll[A1 >: A, B](that: Iterable[B], thisElem: A1, thatElem: B): Chunk[(A1, B)]
Implicitly added by toChunk

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 that is 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 and that. If this immutable sequence is shorter than that, thisElem values are used to pad the result. If that is shorter than this immutable sequence, thatElem values are used to pad the result.

Inherited from:
IterableOps
Source
Iterable.scala

Inherited and Abstract methods

def apply(i: Int): A
Implicitly added by toChunk

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
def length: Int
Implicitly added by toChunk

The length (number of elements) of the immutable sequence. size is an alias for length in Seq collections.

The length (number of elements) of the immutable sequence. size is an alias for length in Seq collections.

Attributes

Inherited from:
SeqOps
Source
Seq.scala

Deprecated and Inherited methods

final def /:[B](z: B)(op: (B, A) => B): B
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use foldLeft instead of /:
Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def :\[B](z: B)(op: (A, B) => B): B
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use foldRight instead of :\\
Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def aggregate[B](z: => B)(seqop: (B, A) => B, combop: (B, B) => B): B
Implicitly added by toChunk

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
def companion: IterableFactory[Chunk]
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use iterableFactory instead
Inherited from:
IterableOps
Source
Iterable.scala
final def copyToBuffer[B >: A](dest: Buffer[B]): Unit
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use `dest ++= coll` instead
Inherited from:
IterableOnceOps
Source
IterableOnce.scala
def hasDefiniteSize: Boolean
Implicitly added by toChunk

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 knownSize for 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 hasDefiniteSize returns false.

Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def prefixLength(p: A => Boolean): Int
Implicitly added by toChunk

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
final def repr: Chunk[A]
Implicitly added by toChunk

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
def reverseMap[B](f: A => B): Chunk[B]
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use .reverseIterator.map(f).to(...) instead of .reverseMap(f)
Inherited from:
SeqOps
Source
Seq.scala
def seq: this.type
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Iterable.seq always returns the iterable itself
Inherited from:
Iterable
Source
Iterable.scala
final def toIterable: this.type
Implicitly added by toChunk

Attributes

Returns

This collection as an Iterable[A]. No new collection will be built if this is already an Iterable[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
final def toIterator: Iterator[A]
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use .iterator instead of .toIterator
Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def toStream: Stream[A]
Implicitly added by toChunk

Attributes

Deprecated
[Since version 2.13.0] Use .to(LazyList) instead of .toStream
Inherited from:
IterableOnceOps
Source
IterableOnce.scala
final def toTraversable: Iterable[A]
Implicitly added by toChunk

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
final def union[B >: A](that: Seq[B]): Chunk[B]
Implicitly added by toChunk

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