ListDecorator

final implicit class ListDecorator[T](val xs: List[T]) extends AnyVal

Implements filterConserve, zipWithConserve methods on lists that avoid duplication of list nodes where feasible.

class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def &(ys: List[T]): List[T]

Intersection on lists seen as sets

Intersection on lists seen as sets

final def eqElements(ys: List[AnyRef]): Boolean
def filterConserve(p: T => Boolean): List[T]

Like xs filter p but returns list xs itself - instead of a copy - if p is true for all elements.

Like xs filter p but returns list xs itself - instead of a copy - if p is true for all elements.

final def hasSameLengthAs[U](ys: List[U]): Boolean

True if two lists have the same length. Since calling length on linear sequences is Θ(n), it is an inadvisable way to test length equality. This method is Θ(n min m).

True if two lists have the same length. Since calling length on linear sequences is Θ(n), it is an inadvisable way to test length equality. This method is Θ(n min m).

def mapWithIndexConserve[U <: T](f: (T, Int) => U): List[U]

Like xs.lazyZip(xs.indices).map(f), but returns list xs itself

Like xs.lazyZip(xs.indices).map(f), but returns list xs itself

  • instead of a copy - if function f maps all elements of xs to themselves.
final def mapconserve[U](f: T => U): List[U]
def zipWithConserve[U, V <: T](ys: List[U])(f: (T, U) => V): List[V]

Like xs.lazyZip(ys).map(f), but returns list xs itself

Like xs.lazyZip(ys).map(f), but returns list xs itself

  • instead of a copy - if function f maps all elements of xs to themselves. Also, it is required that ys is at least as long as xs.
def |(ys: List[T]): List[T]

Union on lists seen as sets

Union on lists seen as sets

Concrete fields

val xs: List[T]