scala.collection.immutable

Members list

Type members

Classlikes

final case class ::[+A](head: A, var next: List[A]) extends List[A]

Attributes

Source
List.scala
Supertypes
trait Product
class List[A]
trait Serializable
trait LinearSeq[A]
trait LinearSeqOps[A, List, List[A]]
trait LinearSeq[A]
trait LinearSeqOps[A, List, List[A]]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, List, List[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, List, List[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, List, List[A]]
trait IterableOnceOps[A, List, List[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
abstract class AbstractMap[K, +V] extends AbstractMap[K, V], Map[K, V]

Explicit instantiation of the Map trait to reduce class file size in subclasses.

Explicit instantiation of the Map trait to reduce class file size in subclasses.

Attributes

Source
Map.scala
Supertypes
trait Map[K, V]
trait MapOps[K, V, Map, Map[K, V]]
trait Iterable[(K, V)]
class AbstractMap[K, V]
trait Map[K, V]
trait Equals
trait MapOps[K, V, Map, Map[K, V]]
trait PartialFunction[K, V]
trait K => V
class AbstractIterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, Map[K, V]]
trait IterableOnceOps[(K, V), Iterable, Map[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
class Map1[K, V]
class Map2[K, V]
class Map3[K, V]
class Map4[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
Show all
abstract class AbstractSeq[+A] extends AbstractSeq[A], Seq[A]

Explicit instantiation of the Seq trait to reduce class file size in subclasses.

Explicit instantiation of the Seq trait to reduce class file size in subclasses.

Attributes

Source
Seq.scala
Supertypes
trait Seq[A]
trait SeqOps[A, Seq, Seq[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, Seq, Seq[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, Seq, Seq[A]]
trait IterableOnceOps[A, Seq, Seq[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
class LazyList[A]
class List[A]
class ::[A]
object Nil.type
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Queue[A]
class Range
class Exclusive
class Inclusive
class Stream[A]
class Cons[A]
object Empty.type
class Vector[A]
Show all
abstract class AbstractSet[A] extends AbstractSet[A], Set[A]

Explicit instantiation of the Set trait to reduce class file size in subclasses.

Explicit instantiation of the Set trait to reduce class file size in subclasses.

Attributes

Source
Set.scala
Supertypes
trait Set[A]
trait SetOps[A, Set, Set[A]]
trait Iterable[A]
class AbstractSet[A]
trait Set[A]
trait Equals
trait SetOps[A, Set, Set[A]]
trait A => Boolean
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, Set, Set[A]]
trait IterableOnceOps[A, Set, Set[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class BitSet
class BitSet1
class BitSet2
class BitSetN
class HashSet[A]
class ListSet[A]
class Set1[A]
class Set2[A]
class Set3[A]
class Set4[A]
class TreeSet[A]
class ValueSet
Show all

An immutable array.

An immutable array.

Supports efficient indexed access and has a small memory footprint.

Attributes

Companion
object
Source
ArraySeq.scala
Supertypes
trait Serializable
trait IndexedSeq[A]
trait IndexedSeq[A]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, ArraySeq, ArraySeq[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, ArraySeq, ArraySeq[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, ArraySeq, ArraySeq[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
Show all

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
ArraySeq.scala
Supertypes
Self type
ArraySeq.type

A class for immutable bitsets.

A class for immutable bitsets.

Bitsets are sets of non-negative integers which are represented as variable-size arrays of bits packed into 64-bit words. The lower bound of memory footprint of a bitset is determined by the largest number stored in it.

Attributes

See also

"Scala's Collection Library overview" section on Immutable BitSets for more information.

Companion
object
Source
BitSet.scala
Supertypes
Known subtypes
class BitSet1
class BitSet2
class BitSetN

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
BitSet.scala
Supertypes
trait Factory[Int, BitSet]
class Object
trait Matchable
class Any
Self type
BitSet.type

This class implements immutable maps using a Compressed Hash-Array Mapped Prefix-tree.

This class implements immutable maps using a Compressed Hash-Array Mapped Prefix-tree. See paper https://michael.steindorfer.name/publications/oopsla15.pdf for more details.

Type parameters

K

the type of the keys contained in this hash set.

V

the type of the values associated with the keys in this hash map.

Attributes

Companion
object
Source
HashMap.scala
Supertypes
trait Serializable
trait StrictOptimizedMapOps[K, V, HashMap, HashMap[K, V]]
trait StrictOptimizedMapOps[K, V, HashMap, HashMap[K, V]]
class AbstractMap[K, V]
trait Map[K, V]
trait MapOps[K, V, HashMap, HashMap[K, V]]
trait Iterable[(K, V)]
class AbstractMap[K, V]
trait Map[K, V]
trait Equals
trait MapOps[K, V, HashMap, HashMap[K, V]]
trait PartialFunction[K, V]
trait K => V
class AbstractIterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, HashMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, HashMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object HashMap extends MapFactory[HashMap]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
HashMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
HashMap.type

This class implements immutable sets using a Compressed Hash-Array Mapped Prefix-tree.

This class implements immutable sets using a Compressed Hash-Array Mapped Prefix-tree. See paper https://michael.steindorfer.name/publications/oopsla15.pdf for more details.

Type parameters

A

the type of the elements contained in this hash set.

Attributes

Companion
object
Source
HashSet.scala
Supertypes
trait Serializable
class AbstractSet[A]
trait Set[A]
trait SetOps[A, HashSet, HashSet[A]]
trait Iterable[A]
class AbstractSet[A]
trait Set[A]
trait Equals
trait SetOps[A, HashSet, HashSet[A]]
trait A => Boolean
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, HashSet, HashSet[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
object HashSet extends IterableFactory[HashSet]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
HashSet.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
HashSet.type

Base trait for immutable indexed sequences that have efficient apply and length

Base trait for immutable indexed sequences that have efficient apply and length

Attributes

Companion
object
Source
Seq.scala
Supertypes
trait IndexedSeq[A]
trait Seq[A]
trait SeqOps[A, IndexedSeq, IndexedSeq[A]]
trait Seq[A]
trait Equals
trait SeqOps[A, IndexedSeq, IndexedSeq[A]]
trait PartialFunction[Int, A]
trait Int => A
trait Iterable[A]
trait Iterable[A]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Range
class Exclusive
class Inclusive
class Vector[A]
Show all
object IndexedSeq extends Delegate[IndexedSeq]

Attributes

Companion
trait
Source
Seq.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
IndexedSeq.type

Attributes

Source
Seq.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait IndexedSeqOps[+A, +CC[_], +C] extends SeqOps[A, CC, C], IndexedSeqOps[A, CC, C]

Base trait for immutable indexed Seq operations

Base trait for immutable indexed Seq operations

Attributes

Source
Seq.scala
Supertypes
trait IndexedSeqOps[A, CC, C]
trait SeqOps[A, CC, C]
trait SeqOps[A, CC, C]
trait IterableOps[A, CC, C]
trait IterableOnceOps[A, CC, C]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
trait IndexedSeq[A]
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Range
class Exclusive
class Inclusive
class Vector[A]
Show all
object IntMap

A companion object for integer maps.

A companion object for integer maps.

Attributes

Companion
class
Source
IntMap.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
IntMap.type
sealed abstract class IntMap[+T] extends AbstractMap[Int, T], StrictOptimizedMapOps[Int, T, Map, IntMap[T]], Serializable

Specialised immutable map structure for integer keys, based on Fast Mergeable Integer Maps by Okasaki and Gill.

Specialised immutable map structure for integer keys, based on Fast Mergeable Integer Maps by Okasaki and Gill. Essentially a trie based on binary digits of the integers.

Note: This class is as of 2.8 largely superseded by HashMap.

Type parameters

T

type of the values associated with integer keys.

Attributes

Companion
object
Source
IntMap.scala
Supertypes
trait Serializable
trait StrictOptimizedMapOps[Int, T, Map, IntMap[T]]
trait StrictOptimizedMapOps[Int, T, Map, IntMap[T]]
class AbstractMap[Int, T]
trait Map[Int, T]
trait MapOps[Int, T, Map, IntMap[T]]
trait Iterable[(Int, T)]
class AbstractMap[Int, T]
trait Map[Int, T]
trait Equals
trait MapFactoryDefaults[Int, T, Map, Iterable]
trait MapOps[Int, T, Map, IntMap[T]]
trait PartialFunction[Int, T]
trait Int => T
class AbstractIterable[(Int, T)]
trait Iterable[(Int, T)]
trait IterableOps[(Int, T), Iterable, IntMap[T]]
trait IterableOnceOps[(Int, T), Iterable, IntMap[T]]
trait IterableOnce[(Int, T)]
class Object
trait Matchable
class Any
Show all

A trait for collections that are guaranteed immutable.

A trait for collections that are guaranteed immutable.

Type parameters

A

the element type of the collection

Attributes

Companion
object
Source
Iterable.scala
Supertypes
trait Iterable[A]
trait IterableOps[A, Iterable, Iterable[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait Map[K, V]
class AbstractMap[K, V]
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
class Map1[K, V]
class Map2[K, V]
class Map3[K, V]
class Map4[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
trait Seq[A]
class AbstractSeq[A]
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
class LazyList[A]
class List[A]
class ::[A]
object Nil.type
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Queue[A]
class Range
class Exclusive
class Inclusive
class Stream[A]
class Cons[A]
object Empty.type
class Vector[A]
trait IndexedSeq[A]
trait LinearSeq[A]
trait Set[A]
class AbstractSet[A]
class BitSet
class BitSet1
class BitSet2
class BitSetN
class HashSet[A]
class ListSet[A]
class Set1[A]
class Set2[A]
class Set3[A]
class Set4[A]
class TreeSet[A]
class ValueSet
trait SortedSet[A]
Show all
object Iterable extends Delegate[Iterable]

Attributes

Companion
trait
Source
Iterable.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
Iterable.type

This class implements an immutable linked list.

This class implements an immutable linked list. We call it "lazy" because it computes its elements only when they are needed.

Elements are memoized; that is, the value of each element is computed at most once.

Elements are computed in-order and are never skipped. In other words, accessing the tail causes the head to be computed first.

How lazy is a LazyList? When you have a value of type LazyList, you don't know yet whether the list is empty or not. If you learn that it is non-empty, then you also know that the head has been computed. But the tail is itself a LazyList, whose emptiness-or-not might remain undetermined.

A LazyList may be infinite. For example, LazyList.from(0) contains all of the natural numbers 0, 1, 2, and so on. For infinite sequences, some methods (such as count, sum, max or min) will not terminate.

Here is an example:

import scala.math.BigInt
object Main extends App {
  val fibs: LazyList[BigInt] =
    BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map{ n => n._1 + n._2 }
  fibs.take(5).foreach(println)
}

// prints
//
// 0
// 1
// 1
// 2
// 3

To illustrate, let's add some output to the definition fibs, so we see what's going on.

import scala.math.BigInt
object Main extends App {
  val fibs: LazyList[BigInt] =
    BigInt(0) #:: BigInt(1) #::
      fibs.zip(fibs.tail).map{ n =>
        println(s"Adding ${n._1} and ${n._2}")
        n._1 + n._2
      }
  fibs.take(5).foreach(println)
  fibs.take(6).foreach(println)
}

// prints
//
// 0
// 1
// Adding 0 and 1
// 1
// Adding 1 and 1
// 2
// Adding 1 and 2
// 3

// And then prints
//
// 0
// 1
// 1
// 2
// 3
// Adding 2 and 3
// 5

Note that the definition of fibs uses val not def. The memoization of the LazyList requires us to have somewhere to store the information and a val allows us to do that.

Further remarks about the semantics of LazyList:

- Though the LazyList changes as it is accessed, this does not contradict its immutability. Once the values are memoized they do not change. Values that have yet to be memoized still "exist", they simply haven't been computed yet.

- One must be cautious of memoization; it can eat up memory if you're not careful. That's because memoization of the LazyList creates a structure much like scala.collection.immutable.List. As long as something is holding on to the head, the head holds on to the tail, and so on recursively. If, on the other hand, there is nothing holding on to the head (e.g. if we used def to define the LazyList) then once it is no longer being used directly, it disappears.

- Note that some operations, including drop, dropWhile, flatMap or collect may process a large number of intermediate elements before returning.

Here's another example. Let's start with the natural numbers and iterate over them.

// We'll start with a silly iteration
def loop(s: String, i: Int, iter: Iterator[Int]): Unit = {
  // Stop after 200,000
  if (i < 200001) {
    if (i % 50000 == 0) println(s + i)
    loop(s, iter.next(), iter)
  }
}

// Our first LazyList definition will be a val definition
val lazylist1: LazyList[Int] = {
  def loop(v: Int): LazyList[Int] = v #:: loop(v + 1)
  loop(0)
}

// Because lazylist1 is a val, everything that the iterator produces is held
// by virtue of the fact that the head of the LazyList is held in lazylist1
val it1 = lazylist1.iterator
loop("Iterator1: ", it1.next(), it1)

// We can redefine this LazyList such that all we have is the Iterator left
// and allow the LazyList to be garbage collected as required.  Using a def
// to provide the LazyList ensures that no val is holding onto the head as
// is the case with lazylist1
def lazylist2: LazyList[Int] = {
  def loop(v: Int): LazyList[Int] = v #:: loop(v + 1)
  loop(0)
}
val it2 = lazylist2.iterator
loop("Iterator2: ", it2.next(), it2)

// And, of course, we don't actually need a LazyList at all for such a simple
// problem.  There's no reason to use a LazyList if you don't actually need
// one.
val it3 = new Iterator[Int] {
  var i = -1
  def hasNext = true
  def next(): Int = { i += 1; i }
}
loop("Iterator3: ", it3.next(), it3)

- In the fibs example earlier, the fact that tail works at all is of interest. fibs has an initial (0, 1, LazyList(...)), so tail is deterministic. If we defined fibs such that only 0 were concretely known, then the act of determining tail would require the evaluation of tail, so the computation would be unable to progress, as in this code:

// The first time we try to access the tail we're going to need more
// information which will require us to recurse, which will require us to
// recurse, which...
lazy val sov: LazyList[Vector[Int]] = Vector(0) #:: sov.zip(sov.tail).map { n => n._1 ++ n._2 }

The definition of fibs above creates a larger number of objects than necessary depending on how you might want to implement it. The following implementation provides a more "cost effective" implementation due to the fact that it has a more direct route to the numbers themselves:

lazy val fib: LazyList[Int] = {
  def loop(h: Int, n: Int): LazyList[Int] = h #:: loop(n, h + n)
  loop(1, 1)
}

The head, the tail and whether the list is empty or not can be initially unknown. Once any of those are evaluated, they are all known, though if the tail is built with #:: or #:::, it's content still isn't evaluated. Instead, evaluating the tails content is deferred until the tails empty status, head or tail is evaluated.

Delaying the evaluation of whether a LazyList is empty or not until it's needed allows LazyList to not eagerly evaluate any elements on a call to filter.

Only when it's further evaluated (which may be never!) any of the elements gets forced.

for example:

def tailWithSideEffect: LazyList[Nothing] = {
  println("getting empty LazyList")
  LazyList.empty
}

val emptyTail = tailWithSideEffect // prints "getting empty LazyList"

val suspended = 1 #:: tailWithSideEffect // doesn't print anything
val tail = suspended.tail // although the tail is evaluated, *still* nothing is yet printed
val filtered = tail.filter(_ => false) // still nothing is printed
filtered.isEmpty // prints "getting empty LazyList"

Type parameters

A

the type of the elements contained in this lazy list.

Attributes

See also

"Scala's Collection Library overview" section on LazyLists for more information.

Companion
object
Source
LazyList.scala
Supertypes
trait Serializable
trait LinearSeq[A]
trait LinearSeq[A]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, LazyList, LazyList[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, LazyList, LazyList[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, LazyList, LazyList[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
object LazyList extends SeqFactory[LazyList]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
LazyList.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
LazyList.type

Base trait for immutable linear sequences that have efficient head and tail

Base trait for immutable linear sequences that have efficient head and tail

Attributes

Companion
object
Source
Seq.scala
Supertypes
trait LinearSeq[A]
trait Seq[A]
trait SeqOps[A, LinearSeq, LinearSeq[A]]
trait Seq[A]
trait Equals
trait SeqOps[A, LinearSeq, LinearSeq[A]]
trait PartialFunction[Int, A]
trait Int => A
trait Iterable[A]
trait Iterable[A]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class LazyList[A]
class List[A]
class ::[A]
object Nil.type
class Queue[A]
class Stream[A]
class Cons[A]
object Empty.type
Show all
object LinearSeq extends Delegate[LinearSeq]

Attributes

Companion
trait
Source
Seq.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
LinearSeq.type
trait LinearSeqOps[+A, +CC <: (LinearSeq), +C <: LinearSeq[A] & LinearSeqOps[A, CC, C]] extends SeqOps[A, CC, C], LinearSeqOps[A, CC, C]

Attributes

Source
Seq.scala
Supertypes
trait LinearSeqOps[A, CC, C]
trait SeqOps[A, CC, C]
trait SeqOps[A, CC, C]
trait IterableOps[A, CC, C]
trait IterableOnceOps[A, CC, C]
trait IterableOnce[A]
class Any
Show all
Known subtypes
class LazyList[A]
trait LinearSeq[A]
class List[A]
class ::[A]
object Nil.type
class Queue[A]
class Stream[A]
class Cons[A]
object Empty.type
Show all

A class for immutable linked lists representing ordered collections of elements of type A.

A class for immutable linked lists representing ordered collections of elements of type A.

This class comes with two implementing case classes scala.Nil and scala.:: that implement the abstract members isEmpty, head and tail.

This class is optimal for last-in-first-out (LIFO), stack-like access patterns. If you need another access pattern, for example, random access or FIFO, consider using a collection more suited to this than List.

Performance

Time: List has O(1) prepend and head/tail access. Most other operations are O(n) on the number of elements in the list. This includes the index-based lookup of elements, length, append and reverse.

Space: List implements structural sharing of the tail list. This means that many operations are either zero- or constant-memory cost.

val mainList = List(3, 2, 1)
val with4 =    4 :: mainList  // re-uses mainList, costs one :: instance
val with42 =   42 :: mainList // also re-uses mainList, cost one :: instance
val shorter =  mainList.tail  // costs nothing as it uses the same 2::1::Nil instances as mainList

Attributes

See also

"Scala's Collection Library overview" section on Lists for more information.

Note

The functional list is characterized by persistence and structural sharing, thus offering considerable performance and space consumption benefits in some scenarios if used correctly. However, note that objects having multiple references into the same functional list (that is, objects that rely on structural sharing), will be serialized and deserialized with multiple lists, one for each reference to it. I.e. structural sharing is lost after serialization/deserialization.

Example

// Make a list via the companion object factory
val days = List("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
// Make a list element-by-element
val when = "AM" :: "PM" :: Nil
// Pattern match
days match {
  case firstDay :: otherDays =>
    println("The first day of the week is: " + firstDay)
  case Nil =>
    println("There don't seem to be any week days.")
}
Companion
object
Source
List.scala
Supertypes
trait Serializable
trait LinearSeq[A]
trait LinearSeqOps[A, List, List[A]]
trait LinearSeq[A]
trait LinearSeqOps[A, List, List[A]]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, List, List[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, List, List[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, List, List[A]]
trait IterableOnceOps[A, List, List[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ::[A]
object Nil.type

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
List.scala
Supertypes
trait Sum
trait Mirror
trait SeqFactory[List]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
List.type
sealed class ListMap[K, +V] extends AbstractMap[K, V], SeqMap[K, V], StrictOptimizedMapOps[K, V, ListMap, ListMap[K, V]], MapFactoryDefaults[K, V, ListMap, Iterable], DefaultSerializable

This class implements immutable maps using a list-based data structure.

This class implements immutable maps using a list-based data structure. List map iterators and traversal methods visit key-value pairs in the order they were first inserted.

Entries are stored internally in reversed insertion order, which means the newest key is at the head of the list. As such, methods such as head and tail are O(n), while last and init are O(1). Other operations, such as inserting or removing entries, are also O(n), which makes this collection suitable only for a small number of elements.

Instances of ListMap represent empty maps; they can be either created by calling the constructor directly, or by applying the function ListMap.empty.

Type parameters

K

the type of the keys contained in this list map

V

the type of the values associated with the keys

Attributes

Companion
object
Source
ListMap.scala
Supertypes
trait Serializable
trait StrictOptimizedMapOps[K, V, ListMap, ListMap[K, V]]
trait StrictOptimizedMapOps[K, V, ListMap, ListMap[K, V]]
trait SeqMap[K, V]
trait SeqMap[K, V]
class AbstractMap[K, V]
trait Map[K, V]
trait MapOps[K, V, ListMap, ListMap[K, V]]
trait Iterable[(K, V)]
class AbstractMap[K, V]
trait Map[K, V]
trait Equals
trait MapOps[K, V, ListMap, ListMap[K, V]]
trait PartialFunction[K, V]
trait K => V
class AbstractIterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, ListMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, ListMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object ListMap extends MapFactory[ListMap]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Note that each element insertion takes O(n) time, which means that creating a list map with n elements will take O(n2) time. This makes the builder suitable only for a small number of elements.

Attributes

See also

"Scala's Collection Library overview" section on List Maps for more information.

Companion
class
Source
ListMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
ListMap.type

This class implements immutable sets using a list-based data structure.

This class implements immutable sets using a list-based data structure. List set iterators and traversal methods visit elements in the order they were first inserted.

Elements are stored internally in reversed insertion order, which means the newest element is at the head of the list. As such, methods such as head and tail are O(n), while last and init are O(1). Other operations, such as inserting or removing entries, are also O(n), which makes this collection suitable only for a small number of elements.

Instances of ListSet represent empty sets; they can be either created by calling the constructor directly, or by applying the function ListSet.empty.

Type parameters

A

the type of the elements contained in this list set

Attributes

Companion
object
Source
ListSet.scala
Supertypes
trait Serializable
class AbstractSet[A]
trait Set[A]
trait SetOps[A, ListSet, ListSet[A]]
trait Iterable[A]
class AbstractSet[A]
trait Set[A]
trait Equals
trait SetOps[A, ListSet, ListSet[A]]
trait A => Boolean
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, ListSet, ListSet[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
object ListSet extends IterableFactory[ListSet]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Note that each element insertion takes O(n) time, which means that creating a list set with n elements will take O(n2) time. This makes the builder suitable only for a small number of elements.

Attributes

Companion
class
Source
ListSet.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
ListSet.type
object LongMap

A companion object for long maps.

A companion object for long maps.

Attributes

Companion
class
Source
LongMap.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
LongMap.type
sealed abstract class LongMap[+T] extends AbstractMap[Long, T], StrictOptimizedMapOps[Long, T, Map, LongMap[T]], Serializable

Specialised immutable map structure for long keys, based on Fast Mergeable Long Maps by Okasaki and Gill.

Specialised immutable map structure for long keys, based on Fast Mergeable Long Maps by Okasaki and Gill. Essentially a trie based on binary digits of the integers.

Note: This class is as of 2.8 largely superseded by HashMap.

Type parameters

T

type of the values associated with the long keys.

Attributes

Companion
object
Source
LongMap.scala
Supertypes
trait Serializable
trait StrictOptimizedMapOps[Long, T, Map, LongMap[T]]
trait StrictOptimizedMapOps[Long, T, Map, LongMap[T]]
class AbstractMap[Long, T]
trait Map[Long, T]
trait MapOps[Long, T, Map, LongMap[T]]
trait Iterable[(Long, T)]
class AbstractMap[Long, T]
trait Map[Long, T]
trait Equals
trait MapFactoryDefaults[Long, T, Map, Iterable]
trait MapOps[Long, T, Map, LongMap[T]]
trait PartialFunction[Long, T]
trait Long => T
class AbstractIterable[(Long, T)]
trait Iterable[(Long, T)]
trait IterableFactoryDefaults[(Long, T), Iterable]
trait IterableOps[(Long, T), Iterable, LongMap[T]]
trait IterableOnceOps[(Long, T), Iterable, LongMap[T]]
trait IterableOnce[(Long, T)]
class Object
trait Matchable
class Any
Show all
trait Map[K, +V] extends Iterable[(K, V)], Map[K, V], MapOps[K, V, Map, Map[K, V]], MapFactoryDefaults[K, V, Map, Iterable]

Base type of immutable Maps

Base type of immutable Maps

Attributes

Companion
object
Source
Map.scala
Supertypes
trait MapOps[K, V, Map, Map[K, V]]
trait Map[K, V]
trait Equals
trait MapOps[K, V, Map, Map[K, V]]
trait PartialFunction[K, V]
trait K => V
trait Iterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, Map[K, V]]
trait IterableOnceOps[(K, V), Iterable, Map[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
class AbstractMap[K, V]
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
class Map1[K, V]
class Map2[K, V]
class Map3[K, V]
class Map4[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
Show all
object Map extends MapFactory[Map]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
trait
Source
Map.scala
Supertypes
trait MapFactory[Map]
trait Serializable
class Object
trait Matchable
class Any
Self type
Map.type
trait MapOps[K, +V, +CC <: (MapOps), +C <: MapOps[K, V, CC, C]] extends IterableOps[(K, V), Iterable, C], MapOps[K, V, CC, C]

Base trait of immutable Maps implementations

Base trait of immutable Maps implementations

Attributes

Source
Map.scala
Supertypes
trait MapOps[K, V, CC, C]
trait PartialFunction[K, V]
trait K => V
trait IterableOps[(K, V), Iterable, C]
trait IterableOnceOps[(K, V), Iterable, C]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait Map[K, V]
class AbstractMap[K, V]
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
class Map1[K, V]
class Map2[K, V]
class Map3[K, V]
class Map4[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
trait SortedMapOps[K, V, CC, C]
trait StrictOptimizedSortedMapOps[K, V, CC, C]
trait StrictOptimizedMapOps[K, V, CC, C]
Show all
sealed class NumericRange[T](val start: T, val end: T, val step: T, val isInclusive: Boolean)(implicit num: Integral[T]) extends AbstractSeq[T], IndexedSeq[T], IndexedSeqOps[T, IndexedSeq, IndexedSeq[T]], StrictOptimizedSeqOps[T, IndexedSeq, IndexedSeq[T]], IterableFactoryDefaults[T, IndexedSeq], Serializable

NumericRange is a more generic version of the Range class which works with arbitrary types.

NumericRange is a more generic version of the Range class which works with arbitrary types. It must be supplied with an Integral implementation of the range type.

Factories for likely types include Range.BigInt, Range.Long, and Range.BigDecimal. Range.Int exists for completeness, but the Int-based scala.Range should be more performant.

val r1 = Range(0, 100, 1)
val veryBig = Int.MaxValue.toLong + 1
val r2 = Range.Long(veryBig, veryBig + 100, 1)
assert(r1 sameElements r2.map(_ - veryBig))

Attributes

Companion
object
Source
NumericRange.scala
Supertypes
trait Serializable
trait IndexedSeq[T]
trait IndexedSeq[T]
class AbstractSeq[T]
trait Seq[T]
trait SeqOps[T, IndexedSeq, IndexedSeq[T]]
trait Iterable[T]
class AbstractSeq[T]
trait Seq[T]
trait Equals
trait SeqOps[T, IndexedSeq, IndexedSeq[T]]
trait PartialFunction[Int, T]
trait Int => T
class AbstractIterable[T]
trait Iterable[T]
trait IterableOnce[T]
class Object
trait Matchable
class Any
Show all
Known subtypes
class Exclusive[T]
class Inclusive[T]
Self type
object NumericRange

A companion object for numeric ranges.

A companion object for numeric ranges.

Attributes

Companion
class
Source
NumericRange.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Queue objects implement data structures that allow to insert and retrieve elements in a first-in-first-out (FIFO) manner.

Queue objects implement data structures that allow to insert and retrieve elements in a first-in-first-out (FIFO) manner.

Queue is implemented as a pair of Lists, one containing the in elements and the other the out elements. Elements are added to the in list and removed from the out list. When the out list runs dry, the queue is pivoted by replacing the out list by in.reverse, and in by Nil.

Adding items to the queue always has cost O(1). Removing items has cost O(1), except in the case where a pivot is required, in which case, a cost of O(n) is incurred, where n is the number of elements in the queue. When this happens, n remove operations with O(1) cost are guaranteed. Removing an item is on average O(1).

Attributes

See also

"Scala's Collection Library overview" section on Immutable Queues for more information.

Companion
object
Source
Queue.scala
Supertypes
trait Serializable
trait LinearSeq[A]
trait LinearSeqOps[A, Queue, Queue[A]]
trait LinearSeq[A]
trait LinearSeqOps[A, Queue, Queue[A]]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, Queue, Queue[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, Queue, Queue[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, Queue, Queue[A]]
trait IterableOnceOps[A, Queue, Queue[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
Queue.scala
Supertypes
trait SeqFactory[Queue]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
Queue.type

The Range class represents integer values in range [start;end) with non-zero step value step.

The Range class represents integer values in range [start;end) with non-zero step value step. It's a special case of an indexed sequence. For example:

val r1 = 0 until 10
val r2 = r1.start until r1.end by r1.step + 1
println(r2.length) // = 5

Ranges that contain more than Int.MaxValue elements can be created, but these overfull ranges have only limited capabilities. Any method that could require a collection of over Int.MaxValue length to be created, or could be asked to index beyond Int.MaxValue elements will throw an exception. Overfull ranges can safely be reduced in size by changing the step size (e.g. by 3) or taking/dropping elements. contains, equals, and access to the ends of the range (head, last, tail, init) are also permitted on overfull ranges.

Value parameters

end

the end of the range. For exclusive ranges, e.g. Range(0,3) or (0 until 3), this is one step past the last one in the range. For inclusive ranges, e.g. Range.inclusive(0,3) or (0 to 3), it may be in the range if it is not skipped by the step size. To find the last element inside a non-empty range, use last instead.

start

the start of this range.

step

the step for the range.

Attributes

Companion
object
Source
Range.scala
Supertypes
Known subtypes
class Exclusive
class Inclusive
Self type
object Range

Companion object for ranges.

Companion object for ranges.

Attributes

Companion
class
Source
Range.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Range.type
trait Seq[+A] extends Iterable[A], Seq[A], SeqOps[A, Seq, Seq[A]], IterableFactoryDefaults[A, Seq]

Attributes

Companion
object
Source
Seq.scala
Supertypes
trait SeqOps[A, Seq, Seq[A]]
trait Seq[A]
trait Equals
trait SeqOps[A, Seq, Seq[A]]
trait PartialFunction[Int, A]
trait Int => A
trait Iterable[A]
trait Iterable[A]
trait IterableOps[A, Seq, Seq[A]]
trait IterableOnceOps[A, Seq, Seq[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class AbstractSeq[A]
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
class LazyList[A]
class List[A]
class ::[A]
object Nil.type
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Queue[A]
class Range
class Exclusive
class Inclusive
class Stream[A]
class Cons[A]
object Empty.type
class Vector[A]
trait IndexedSeq[A]
trait LinearSeq[A]
Show all
object Seq extends Delegate[Seq]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
trait
Source
Seq.scala
Supertypes
class Delegate[Seq]
trait SeqFactory[Seq]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
Seq.type
trait SeqMap[K, +V] extends Map[K, V], SeqMap[K, V], MapOps[K, V, SeqMap, SeqMap[K, V]], MapFactoryDefaults[K, V, SeqMap, Iterable]

A base trait for ordered, immutable maps.

A base trait for ordered, immutable maps.

Note that the equals method for SeqMap compares key-value pairs without regard to ordering.

All behavior is defined in terms of the abstract methods in SeqMap. It is sufficient for concrete subclasses to implement those methods. Methods that return a new map, in particular removed and updated, must preserve ordering.

Type parameters

K

the type of the keys contained in this linked map.

V

the type of the values associated with the keys in this linked map.

Attributes

Companion
object
Source
SeqMap.scala
Supertypes
trait SeqMap[K, V]
trait Map[K, V]
trait MapOps[K, V, SeqMap, SeqMap[K, V]]
trait Map[K, V]
trait Equals
trait MapOps[K, V, SeqMap, SeqMap[K, V]]
trait PartialFunction[K, V]
trait K => V
trait Iterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, SeqMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, SeqMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ListMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
object SeqMap extends MapFactory[SeqMap]

Attributes

Companion
trait
Source
SeqMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
SeqMap.type
trait SeqOps[+A, +CC[_], +C] extends SeqOps[A, CC, C]

Attributes

Source
Seq.scala
Supertypes
trait SeqOps[A, CC, C]
trait IterableOps[A, CC, C]
trait IterableOnceOps[A, CC, C]
trait IterableOnce[A]
class Any
Known subtypes
trait IndexedSeqOps[A, CC, C]
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
trait IndexedSeq[A]
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Range
class Exclusive
class Inclusive
class Vector[A]
trait LinearSeqOps[A, CC, C]
class LazyList[A]
trait LinearSeq[A]
class List[A]
class ::[A]
object Nil.type
class Queue[A]
class Stream[A]
class Cons[A]
object Empty.type
trait Seq[A]
class AbstractSeq[A]
trait StrictOptimizedSeqOps[A, CC, C]
Show all
trait Set[A] extends Iterable[A], Set[A], SetOps[A, Set, Set[A]], IterableFactoryDefaults[A, Set]

Base trait for immutable set collections

Base trait for immutable set collections

Attributes

Companion
object
Source
Set.scala
Supertypes
trait SetOps[A, Set, Set[A]]
trait Set[A]
trait Equals
trait SetOps[A, Set, Set[A]]
trait A => Boolean
trait Iterable[A]
trait Iterable[A]
trait IterableOps[A, Set, Set[A]]
trait IterableOnceOps[A, Set, Set[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class AbstractSet[A]
class BitSet
class BitSet1
class BitSet2
class BitSetN
class HashSet[A]
class ListSet[A]
class Set1[A]
class Set2[A]
class Set3[A]
class Set4[A]
class TreeSet[A]
class ValueSet
trait SortedSet[A]
Show all
object Set extends IterableFactory[Set]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
trait
Source
Set.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
Set.type
trait SetOps[A, +CC[X], +C <: SetOps[A, CC, C]] extends SetOps[A, CC, C]

Base trait for immutable set operations

Base trait for immutable set operations

Attributes

Source
Set.scala
Supertypes
trait SetOps[A, CC, C]
trait A => Boolean
trait IterableOps[A, CC, C]
trait IterableOnceOps[A, CC, C]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait Set[A]
class AbstractSet[A]
class BitSet
class BitSet1
class BitSet2
class BitSetN
class HashSet[A]
class ListSet[A]
class Set1[A]
class Set2[A]
class Set3[A]
class Set4[A]
class TreeSet[A]
class ValueSet
trait SortedSet[A]
trait SortedSetOps[A, CC, C]
trait StrictOptimizedSortedSetOps[A, CC, C]
trait StrictOptimizedSetOps[A, CC, C]
Show all
trait SortedMap[K, +V] extends Map[K, V], SortedMap[K, V], SortedMapOps[K, V, SortedMap, SortedMap[K, V]], SortedMapFactoryDefaults[K, V, SortedMap, Iterable, Map]

An immutable map whose key-value pairs are sorted according to an scala.math.Ordering on the keys.

An immutable map whose key-value pairs are sorted according to an scala.math.Ordering on the keys.

Allows for range queries to be performed on its keys, and implementations must guarantee that traversal happens in sorted order, according to the map's scala.math.Ordering.

Type parameters

K

the type of the keys contained in this tree map.

V

the type of the values associated with the keys.

Attributes

Example

import scala.collection.immutable.SortedMap
// Make a SortedMap via the companion object factory
val weekdays = SortedMap(
  2 -> "Monday",
  3 -> "Tuesday",
  4 -> "Wednesday",
  5 -> "Thursday",
  6 -> "Friday"
)
// TreeMap(2 -> Monday, 3 -> Tuesday, 4 -> Wednesday, 5 -> Thursday, 6 -> Friday)
val days = weekdays ++ List(1 -> "Sunday", 7 -> "Saturday")
// TreeMap(1 -> Sunday, 2 -> Monday, 3 -> Tuesday, 4 -> Wednesday, 5 -> Thursday, 6 -> Friday, 7 -> Saturday)
val day3 = days.get(3) // Some("Tuesday")
val rangeOfDays = days.range(2, 5) // TreeMap(2 -> Monday, 3 -> Tuesday, 4 -> Wednesday)
val daysUntil2 = days.rangeUntil(2) // TreeMap(1 -> Sunday)
val daysTo2 = days.rangeTo(2) // TreeMap(1 -> Sunday, 2 -> Monday)
val daysAfter5 = days.rangeFrom(5) //  TreeMap(5 -> Thursday, 6 -> Friday, 7 -> Saturday)
Companion
object
Source
SortedMap.scala
Supertypes
trait SortedMapOps[K, V, SortedMap, SortedMap[K, V]]
trait SortedMap[K, V]
trait SortedMapOps[K, V, SortedMap, SortedMap[K, V]]
trait SortedOps[K, SortedMap[K, V]]
trait Map[K, V]
trait MapOps[K, V, Map, SortedMap[K, V]]
trait Map[K, V]
trait Equals
trait MapOps[K, V, Map, SortedMap[K, V]]
trait PartialFunction[K, V]
trait K => V
trait Iterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, SortedMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, SortedMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
class WithDefault[K, V]
class TreeMap[K, V]
object SortedMap extends Delegate[SortedMap]

Attributes

Companion
trait
Source
SortedMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
SortedMap.type
trait SortedMapOps[K, +V, +CC <: ([X, Y] =>> Map[X, Y] & SortedMapOps[X, Y, CC, _]), +C <: SortedMapOps[K, V, CC, C]] extends MapOps[K, V, Map, C], SortedMapOps[K, V, CC, C]

Attributes

Source
SortedMap.scala
Supertypes
trait SortedMapOps[K, V, CC, C]
trait SortedOps[K, C]
trait MapOps[K, V, Map, C]
trait MapOps[K, V, Map, C]
trait PartialFunction[K, V]
trait K => V
trait IterableOps[(K, V), Iterable, C]
trait IterableOnceOps[(K, V), Iterable, C]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait SortedMap[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
trait StrictOptimizedSortedMapOps[K, V, CC, C]
Self type
SortedMapOps[K, V, CC, C]

Base trait for sorted sets

Base trait for sorted sets

Attributes

Companion
object
Source
SortedSet.scala
Supertypes
trait SortedSet[A]
trait SortedOps[A, SortedSet[A]]
trait Set[A]
trait SetOps[A, Set, SortedSet[A]]
trait Set[A]
trait Equals
trait SetOps[A, Set, SortedSet[A]]
trait (A) => Boolean
trait Iterable[A]
trait Iterable[A]
trait IterableOps[A, Set, SortedSet[A]]
trait IterableOnceOps[A, Set, SortedSet[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class BitSet
class BitSet1
class BitSet2
class BitSetN
class TreeSet[A]
class ValueSet
Show all
object SortedSet extends Delegate[SortedSet]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
trait
Source
SortedSet.scala
Supertypes
Self type
SortedSet.type
trait SortedSetOps[A, +CC <: (SortedSet), +C <: SortedSetOps[A, CC, C]] extends SetOps[A, Set, C], SortedSetOps[A, CC, C]

Attributes

Source
SortedSet.scala
Supertypes
trait SortedSetOps[A, CC, C]
trait SortedOps[A, C]
trait SetOps[A, Set, C]
trait SetOps[A, Set, C]
trait A => Boolean
trait IterableOps[A, Set, C]
trait IterableOnceOps[A, Set, C]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class BitSet
class BitSet1
class BitSet2
class BitSetN
trait SortedSet[A]
class TreeSet[A]
class ValueSet
trait StrictOptimizedSortedSetOps[A, CC, C]
Show all
trait StrictOptimizedMapOps[K, +V, +CC <: (MapOps), +C <: MapOps[K, V, CC, C]] extends MapOps[K, V, CC, C], StrictOptimizedMapOps[K, V, CC, C], StrictOptimizedIterableOps[(K, V), Iterable, C]

Attributes

Source
Map.scala
Supertypes
trait StrictOptimizedMapOps[K, V, CC, C]
trait MapOps[K, V, CC, C]
trait MapOps[K, V, CC, C]
trait PartialFunction[K, V]
trait K => V
trait IterableOps[(K, V), Iterable, C]
trait IterableOnceOps[(K, V), Iterable, C]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
trait StrictOptimizedSortedMapOps[K, V, CC, C]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
Show all
trait StrictOptimizedSeqOps[+A, +CC[_], +C] extends SeqOps[A, CC, C], StrictOptimizedSeqOps[A, CC, C], StrictOptimizedIterableOps[A, CC, C]

Trait that overrides operations to take advantage of strict builders.

Trait that overrides operations to take advantage of strict builders.

Attributes

Source
StrictOptimizedSeqOps.scala
Supertypes
trait StrictOptimizedSeqOps[A, CC, C]
trait StrictOptimizedIterableOps[A, CC, C]
trait SeqOps[A, CC, C]
trait SeqOps[A, CC, C]
trait IterableOps[A, CC, C]
trait IterableOnceOps[A, CC, C]
trait IterableOnce[A]
class Any
Show all
Known subtypes
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
class List[A]
class ::[A]
object Nil.type
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Queue[A]
class Range
class Exclusive
class Inclusive
class Vector[A]
Show all
trait StrictOptimizedSetOps[A, +CC[X], +C <: SetOps[A, CC, C]] extends SetOps[A, CC, C], StrictOptimizedSetOps[A, CC, C], StrictOptimizedIterableOps[A, CC, C]

Attributes

Source
Set.scala
Supertypes
trait StrictOptimizedSetOps[A, CC, C]
trait StrictOptimizedIterableOps[A, CC, C]
trait SetOps[A, CC, C]
trait SetOps[A, CC, C]
trait A => Boolean
trait IterableOps[A, CC, C]
trait IterableOnceOps[A, CC, C]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class HashSet[A]
class ListSet[A]
trait StrictOptimizedSortedSetOps[A, CC, C]
class BitSet
class BitSet1
class BitSet2
class BitSetN
class TreeSet[A]
Show all
trait StrictOptimizedSortedMapOps[K, +V, +CC <: ([X, Y] =>> Map[X, Y] & SortedMapOps[X, Y, CC, _]), +C <: SortedMapOps[K, V, CC, C]] extends SortedMapOps[K, V, CC, C], StrictOptimizedSortedMapOps[K, V, CC, C], StrictOptimizedMapOps[K, V, Map, C]

Attributes

Source
SortedMap.scala
Supertypes
trait StrictOptimizedMapOps[K, V, Map, C]
trait StrictOptimizedSortedMapOps[K, V, CC, C]
trait StrictOptimizedMapOps[K, V, Map, C]
trait SortedMapOps[K, V, CC, C]
trait SortedMapOps[K, V, CC, C]
trait SortedOps[K, C]
trait MapOps[K, V, Map, C]
trait MapOps[K, V, Map, C]
trait PartialFunction[K, V]
trait K => V
trait IterableOps[(K, V), Iterable, C]
trait IterableOnceOps[(K, V), Iterable, C]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
Known subtypes
class TreeMap[K, V]
trait StrictOptimizedSortedSetOps[A, +CC <: (SortedSet), +C <: SortedSetOps[A, CC, C]] extends SortedSetOps[A, CC, C], StrictOptimizedSortedSetOps[A, CC, C], StrictOptimizedSetOps[A, Set, C]

Attributes

Source
SortedSet.scala
Supertypes
trait StrictOptimizedSetOps[A, Set, C]
trait StrictOptimizedSortedSetOps[A, CC, C]
trait StrictOptimizedSetOps[A, Set, C]
trait SortedSetOps[A, CC, C]
trait SortedSetOps[A, CC, C]
trait SortedOps[A, C]
trait SetOps[A, Set, C]
trait SetOps[A, Set, C]
trait A => Boolean
trait IterableOps[A, Set, C]
trait IterableOnceOps[A, Set, C]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class BitSet
class BitSet1
class BitSet2
class BitSetN
class TreeSet[A]

An immutable SortedMap whose values are stored in a red-black tree.

An immutable SortedMap whose values are stored in a red-black tree.

This class is optimal when range queries will be performed, or when traversal in order of an ordering is desired. If you only need key lookups, and don't care in which order key-values are traversed in, consider using * scala.collection.immutable.HashMap, which will generally have better performance. If you need insertion order, consider a * scala.collection.immutable.SeqMap, which does not need to have an ordering supplied.

Type parameters

K

the type of the keys contained in this tree map.

V

the type of the values associated with the keys.

Value parameters

ordering

the implicit ordering used to compare objects of type A.

Attributes

See also

"Scala's Collection Library overview" section on Red-Black Trees for more information.

Example

import scala.collection.immutable.TreeMap
// Make a TreeMap via the companion object factory
val weekdays = TreeMap(
  2 -> "Monday",
  3 -> "Tuesday",
  4 -> "Wednesday",
  5 -> "Thursday",
  6 -> "Friday"
)
// TreeMap(2 -> Monday, 3 -> Tuesday, 4 -> Wednesday, 5 -> Thursday, 6 -> Friday)
val days = weekdays ++ List(1 -> "Sunday", 7 -> "Saturday")
// TreeMap(1 -> Sunday, 2 -> Monday, 3 -> Tuesday, 4 -> Wednesday, 5 -> Thursday, 6 -> Friday, 7 -> Saturday)
val day3 = days.get(3) // Some("Tuesday")
val rangeOfDays = days.range(2, 5) // TreeMap(2 -> Monday, 3 -> Tuesday, 4 -> Wednesday)
val daysUntil2 = days.rangeUntil(2) // TreeMap(1 -> Sunday)
val daysTo2 = days.rangeTo(2) // TreeMap(1 -> Sunday, 2 -> Monday)
val daysAfter5 = days.rangeFrom(5) //  TreeMap(5 -> Thursday, 6 -> Friday, 7 -> Saturday)
Companion
object
Source
TreeMap.scala
Supertypes
trait Serializable
trait StrictOptimizedMapOps[K, V, Map, TreeMap[K, V]]
trait StrictOptimizedMapOps[K, V, Map, TreeMap[K, V]]
trait SortedMap[K, V]
trait SortedMapOps[K, V, TreeMap, TreeMap[K, V]]
trait SortedMap[K, V]
trait SortedMapOps[K, V, TreeMap, TreeMap[K, V]]
trait SortedOps[K, TreeMap[K, V]]
class AbstractMap[K, V]
trait Map[K, V]
trait MapOps[K, V, Map, TreeMap[K, V]]
trait Iterable[(K, V)]
class AbstractMap[K, V]
trait Map[K, V]
trait Equals
trait MapOps[K, V, Map, TreeMap[K, V]]
trait PartialFunction[K, V]
trait K => V
class AbstractIterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, TreeMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, TreeMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object TreeMap extends SortedMapFactory[TreeMap]

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
TreeMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
TreeMap.type

This class implements an immutable map that preserves order using a hash map for the key to value mapping to provide efficient lookup, and a tree for the ordering of the keys to provide efficient insertion/modification order traversal and destructuring.

This class implements an immutable map that preserves order using a hash map for the key to value mapping to provide efficient lookup, and a tree for the ordering of the keys to provide efficient insertion/modification order traversal and destructuring.

By default insertion order (TreeSeqMap.OrderBy.Insertion) is used, but modification order (TreeSeqMap.OrderBy.Modification) can be used instead if so specified at creation.

The orderingBy(orderBy: TreeSeqMap.OrderBy): TreeSeqMap[K, V] method can be used to switch to the specified ordering for the returned map.

A key can be manually refreshed (i.e. placed at the end) via the refresh(key: K): TreeSeqMap[K, V] method (regardless of the ordering in use).

Internally, an ordinal counter is increased for each insertion/modification and then the current ordinal is used as key in the tree map. After 232 insertions/modifications the entire map is copied (thus resetting the ordinal counter).

Type parameters

K

the type of the keys contained in this map.

V

the type of the values associated with the keys in this map.

Attributes

Companion
object
Source
TreeSeqMap.scala
Supertypes
trait SeqMap[K, V]
trait SeqMap[K, V]
class AbstractMap[K, V]
trait Map[K, V]
trait MapOps[K, V, TreeSeqMap, TreeSeqMap[K, V]]
trait Iterable[(K, V)]
class AbstractMap[K, V]
trait Map[K, V]
trait Equals
trait MapOps[K, V, TreeSeqMap, TreeSeqMap[K, V]]
trait PartialFunction[K, V]
trait K => V
class AbstractIterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, TreeSeqMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, TreeSeqMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object TreeSeqMap extends MapFactory[TreeSeqMap]

Attributes

Companion
class
Source
TreeSeqMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
TreeSeqMap.type

This class implements immutable sorted sets using a tree.

This class implements immutable sorted sets using a tree.

Type parameters

A

the type of the elements contained in this tree set

Value parameters

ordering

the implicit ordering used to compare objects of type A

Attributes

See also

"Scala's Collection Library overview" section on Red-Black Trees for more information.

Companion
object
Source
TreeSet.scala
Supertypes
trait Serializable
trait SortedSet[A]
trait SortedSetOps[A, TreeSet, TreeSet[A]]
trait SortedSet[A]
trait SortedSetOps[A, TreeSet, TreeSet[A]]
trait SortedOps[A, TreeSet[A]]
class AbstractSet[A]
trait Set[A]
trait SetOps[A, Set, TreeSet[A]]
trait Iterable[A]
class AbstractSet[A]
trait Set[A]
trait Equals
trait SetOps[A, Set, TreeSet[A]]
trait (A) => Boolean
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, Set, TreeSet[A]]
trait IterableOnceOps[A, Set, TreeSet[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
TreeSet.scala
Supertypes
Self type
TreeSet.type

This object provides a set of operations to create Iterable values.

This object provides a set of operations to create Iterable values.

Attributes

Companion
class
Source
Vector.scala
Supertypes
Self type
Vector.type

Vector is a general-purpose, immutable data structure.

Vector is a general-purpose, immutable data structure. It provides random access and updates in O(log n) time, as well as very fast append/prepend/tail/init (amortized O(1), worst case O(log n)). Because vectors strike a good balance between fast random selections and fast random functional updates, they are currently the default implementation of immutable indexed sequences.

Vectors are implemented by radix-balanced finger trees of width 32. There is a separate subclass for each level (0 to 6, with 0 being the empty vector and 6 a tree with a maximum width of 64 at the top level).

Tree balancing: - Only the first dimension of an array may have a size < WIDTH - In a data (central) array the first dimension may be up to WIDTH-2 long, in prefix1 and suffix1 up to WIDTH, and in other prefix and suffix arrays up to WIDTH-1 - prefix1 and suffix1 are never empty - Balancing does not cross the main data array (i.e. prepending never touches the suffix and appending never touches the prefix). The level is increased/decreased when the affected side plus main data is already full/empty - All arrays are left-aligned and truncated

In addition to the data slices (prefix1, prefix2, ..., dataN, ..., suffix2, suffix1) we store a running count of elements after each prefix for more efficient indexing without having to dereference all prefix arrays.

Attributes

Companion
object
Source
Vector.scala
Supertypes
trait Serializable
trait IndexedSeq[A]
trait IndexedSeqOps[A, Vector, Vector[A]]
trait IndexedSeq[A]
trait IndexedSeqOps[A, Vector, Vector[A]]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, Vector, Vector[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, Vector, Vector[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, Vector, Vector[A]]
trait IterableOnceOps[A, Vector, Vector[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
final class VectorBuilder[A] extends ReusableBuilder[A, Vector[A]]

Attributes

Source
Vector.scala
Supertypes
trait ReusableBuilder[A, Vector[A]]
trait Builder[A, Vector[A]]
trait Growable[A]
trait Clearable
class Object
trait Matchable
class Any
Show all
final class VectorMap[K, +V] extends AbstractMap[K, V], SeqMap[K, V], StrictOptimizedMapOps[K, V, VectorMap, VectorMap[K, V]], MapFactoryDefaults[K, V, VectorMap, Iterable]

This class implements immutable maps using a vector/map-based data structure, which preserves insertion order.

This class implements immutable maps using a vector/map-based data structure, which preserves insertion order.

Unlike ListMap, VectorMap has amortized effectively constant lookup at the expense of using extra memory and generally lower performance for other operations

Type parameters

K

the type of the keys contained in this vector map.

V

the type of the values associated with the keys in this vector map.

Attributes

Companion
object
Source
VectorMap.scala
Supertypes
trait SeqMap[K, V]
trait SeqMap[K, V]
class AbstractMap[K, V]
trait Map[K, V]
trait MapOps[K, V, VectorMap, VectorMap[K, V]]
trait Iterable[(K, V)]
class AbstractMap[K, V]
trait Map[K, V]
trait Equals
trait MapOps[K, V, VectorMap, VectorMap[K, V]]
trait PartialFunction[K, V]
trait K => V
class AbstractIterable[(K, V)]
trait Iterable[(K, V)]
trait IterableOps[(K, V), Iterable, VectorMap[K, V]]
trait IterableOnceOps[(K, V), Iterable, VectorMap[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object VectorMap extends MapFactory[VectorMap]

Attributes

Companion
class
Source
VectorMap.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
VectorMap.type

This class serves as a wrapper augmenting Strings with all the operations found in indexed sequences.

This class serves as a wrapper augmenting Strings with all the operations found in indexed sequences.

The difference between this class and StringOps is that calling transformer methods such as filter and map will yield an object of type WrappedString rather than a String.

Value parameters

self

a string contained within this wrapped string

Attributes

Companion
object
Source
WrappedString.scala
Supertypes

A companion object for wrapped strings.

A companion object for wrapped strings.

Attributes

Companion
class
Source
WrappedString.scala
Supertypes
Self type

Deprecated classlikes

sealed abstract class Stream[+A] extends AbstractSeq[A], LinearSeq[A], LinearSeqOps[A, Stream, Stream[A]], IterableFactoryDefaults[A, Stream], Serializable

Attributes

Companion
object
Deprecated
true
Source
Stream.scala
Supertypes
trait Serializable
trait LinearSeq[A]
trait LinearSeqOps[A, Stream, Stream[A]]
trait LinearSeq[A]
trait LinearSeqOps[A, Stream, Stream[A]]
class AbstractSeq[A]
trait Seq[A]
trait SeqOps[A, Stream, Stream[A]]
trait Iterable[A]
class AbstractSeq[A]
trait Seq[A]
trait Equals
trait SeqOps[A, Stream, Stream[A]]
trait PartialFunction[Int, A]
trait Int => A
class AbstractIterable[A]
trait Iterable[A]
trait IterableOps[A, Stream, Stream[A]]
trait IterableOnceOps[A, Stream, Stream[A]]
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class Cons[A]
object Empty.type
object Stream extends SeqFactory[Stream]

Attributes

Companion
class
Deprecated
true
Source
Stream.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
Stream.type

Types

Attributes

Source
package.scala

Attributes

Source
package.scala

Deprecated types

type DefaultMap[K, +V] = Map[K, V]

Attributes

Deprecated
true
Source
package.scala
type Traversable[+X] = Iterable[X]

Attributes

Deprecated
true
Source
package.scala

Value members

Concrete fields

val StringOps: StringOps.type

Attributes

Source
package.scala
val StringView: StringView.type

Attributes

Source
package.scala

Deprecated fields

val Traversable: Iterable.type

Attributes

Deprecated
true
Source
package.scala