SeqDecorator

scala.collection.decorators.SeqDecorator
class SeqDecorator[C, S <: IsSeq[C]](coll: C)(implicit val seq: S)

Attributes

C

type of the decorated collection (e.g. List[Int], String, etc.)

coll

the decorated collection

seq

evidence that type C is a sequence

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def intersperse[B >: A, That](sep: B)(implicit bf: BuildFrom[C, B, That]): That

Adds the element sep between each element of the sequence. If the sequence has less than two elements, the collection is unchanged.

Adds the element sep between each element of the sequence. If the sequence has less than two elements, the collection is unchanged.

Attributes

B

the element type of the returned collection

sep

the element to intersperse

Returns:

a new collection consisting of all elements of this collection interspersed with the element sep

Example:
List(1, 2, 3, 4).intersperse(0) = List(1, 0, 2, 0, 3, 0, 4)
def intersperse[B >: A, That](start: B, sep: B, end: B)(implicit bf: BuildFrom[C, B, That]): That

Adds the element sep between each element of the sequence, prepending start and appending end. If the sequence has less than two elements, returns start +: this :+ end.

Adds the element sep between each element of the sequence, prepending start and appending end. If the sequence has less than two elements, returns start +: this :+ end.

Attributes

B

the element type of the returned collection

end

the element to append

sep

the element to intersperse

start

the element to prepend

Returns:

a new collection consisting of all elements of this collection interspersed with the element sep, beginning with start and ending with end

Example:
    List(1, 2, 3, 4).intersperse(-1, 0, 5) => List(-1, 1, 0, 2, 0, 3, 0, 4, 5)
def replaced[B >: A, That](elem: B, replacement: B)(implicit bf: BuildFrom[C, B, That]): That

Produces a new sequence where all occurrences of some element are replaced by a different element.

Produces a new sequence where all occurrences of some element are replaced by a different element.

Attributes

B

the element type of the returned collection.

elem

the element to replace

replacement

the replacement element

Returns:

a new sequence consisting of all elements of this sequence except that all occurrences of elem are replaced by replacement

Implicits

Implicits

implicit val seq: S