Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/scala.collection/scala.collection.immutable

scala.collection.immutable

Members list

Type members

Classlikes

final caseclass::[+A](head:A,varnext:List[A]) extendsList[A]

Attributes

Source
List.scala
Supertypes
traitProduct
classList[A]
traitLinearSeq[A]
traitLinearSeqOps[A,List,List[A]]
traitLinearSeq[A]
traitLinearSeqOps[A,List,List[A]]
classAbstractSeq[A]
traitSeq[A]
traitSeqOps[A,List,List[A]]
traitIterable[A]
classAbstractSeq[A]
traitSeq[A]
traitEquals
traitSeqOps[A,List,List[A]]
traitInt=>A
traitIterable[A]
traitIterableOps[A,List,List[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
abstractclassAbstractMap[K,+V] extendsAbstractMap[K,V],Map[K,V]

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

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

Attributes

Source
Map.scala
Supertypes
traitMap[K,V]
traitMapOps[K,V,Map,Map[K,V]]
traitIterable[(K,V)]
classAbstractMap[K,V]
traitMap[K,V]
traitEquals
traitMapOps[K,V,Map,Map[K,V]]
traitPartialFunction[K,V]
traitK=>V
classAbstractIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,Map[K,V]]
traitIterableOnceOps[(K,V),Iterable,Map[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
Show all
abstractclassAbstractSeq[+A] extendsAbstractSeq[A],Seq[A]

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

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

Attributes

Source
Seq.scala
Supertypes
traitSeq[A]
traitSeqOps[A,Seq,Seq[A]]
traitIterable[A]
classAbstractSeq[A]
traitSeq[A]
traitEquals
traitSeqOps[A,Seq,Seq[A]]
traitInt=>A
traitIterable[A]
traitIterableOps[A,Seq,Seq[A]]
traitIterableOnceOps[A,Seq,Seq[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
Show all
abstractclassAbstractSet[A] extendsAbstractSet[A],Set[A]

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

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

Attributes

Source
Set.scala
Supertypes
traitSet[A]
traitSetOps[A,Set,Set[A]]
traitIterable[A]
classAbstractSet[A]
traitSet[A]
traitEquals
traitSetOps[A,Set,Set[A]]
traitA=>Boolean
traitIterable[A]
traitIterableOps[A,Set,Set[A]]
traitIterableOnceOps[A,Set,Set[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
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
Known subtypes
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
Show all

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
class
Source
ArraySeq.scala
Supertypes
Self 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 onImmutable BitSets for more information.

Companion
object
Source
BitSet.scala
Supertypes
traitBitSet
traitSortedSet[Int]
traitSortedSet[Int]
traitSet[Int]
traitIterable[Int]
traitSet[Int]
traitEquals
traitInt=>Boolean
traitIterable[Int]
classObject
traitMatchable
classAny
Show all
Known subtypes
classBitSet1
classBitSet2
classBitSetN

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
class
Source
BitSet.scala
Supertypes
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
classAbstractMap[K,V]
traitMap[K,V]
traitMapOps[K,V,HashMap,HashMap[K,V]]
traitIterable[(K,V)]
classAbstractMap[K,V]
traitMap[K,V]
traitEquals
traitMapOps[K,V,HashMap,HashMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
classAbstractIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,HashMap[K,V]]
traitIterableOnceOps[(K,V),Iterable,HashMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
objectHashMap extendsMapFactory[HashMap]

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
class
Source
HashMap.scala
Supertypes
classObject
traitMatchable
classAny
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

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

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

Base trait for immutable indexed sequences that have efficientapply andlength

Base trait for immutable indexed sequences that have efficientapply andlength

Attributes

Companion
object
Source
Seq.scala
Supertypes
Known subtypes
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classRange
classExclusive
classInclusive
classVector[A]
Show all

Attributes

Companion
trait
Source
Seq.scala
Supertypes
Self type

Attributes

Source
Seq.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitIndexedSeqOps[+A,+CC[_],+C] extendsSeqOps[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
traitIndexedSeqOps[A,CC,C]
traitSeqOps[A,CC,C]
traitSeqOps[A,CC,C]
traitIterableOps[A,CC,C]
traitIterableOnceOps[A,CC,C]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
traitIndexedSeq[A]
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classRange
classExclusive
classInclusive
classVector[A]
Show all
objectIntMap

A companion object for integer maps.

A companion object for integer maps.

Attributes

Companion
class
Source
IntMap.scala
Supertypes
classObject
traitMatchable
classAny
Self type
IntMap.type
sealed abstractclassIntMap[+T] extendsAbstractMap[Int,T],StrictOptimizedMapOps[Int,T,Map,IntMap[T]],Serializable

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

Specialised immutable map structure for integer keys, based onFast 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

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
Known subtypes
traitMap[K,V]
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSeq[A]
classAbstractSeq[A]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
traitIndexedSeq[A]
traitLinearSeq[A]
traitSet[A]
classAbstractSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
traitSortedSet[A]
Show all
objectIterable extendsDelegate[Iterable]

Attributes

Companion
trait
Source
Iterable.scala
Supertypes
classObject
traitMatchable
classAny
Show all
Self 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 aLazyList? When you have a value of typeLazyList, 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 aLazyList, whose emptiness-or-not might remain undetermined.

ALazyList 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 ascount,sum,max ormin) will not terminate.

Here is an example:

import scala.math.BigIntobject 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 definitionfibs, so we see what's going on.

import scala.math.BigIntobject 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 offibs usesval notdef. The memoization of theLazyList requires us to have somewhere to store the information and aval allows us to do that.

Further remarks about the semantics ofLazyList:

- Though theLazyList 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 theLazyList creates a structure much likescala.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 useddef to define theLazyList) then once it is no longer being used directly, it disappears.

- Note that some operations, includingdrop,dropWhile,flatMap orcollect 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 iterationdef 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 definitionval 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 lazylist1val it1 = lazylist1.iteratorloop("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 lazylist1def lazylist2: LazyList[Int] = {  def loop(v: Int): LazyList[Int] = v #:: loop(v + 1)  loop(0)}val it2 = lazylist2.iteratorloop("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 thefibs example earlier, the fact thattail works at all is of interest.fibs has an initial(0, 1, LazyList(...)), sotail is deterministic. If we definedfibs such that only0 were concretely known, then the act of determiningtail would require the evaluation oftail, 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 offibs 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 tofilter.

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 anythingval tail = suspended.tail // although the tail is evaluated, *still* nothing is yet printedval filtered = tail.filter(_ => false) // still nothing is printedfiltered.isEmpty // prints "getting empty LazyList"

You may sometimes encounter an exception like the following:

java.lang.RuntimeException: "LazyList evaluation depends on its own result (self-reference); see docs for more info

This exception occurs when aLazyList is attempting to derive its next element from itself, and is attempting to read the element currently being evaluated. A trivial example of such might be

lazy val a: LazyList[Int] = 1 #:: 2 #:: a.filter(_ > 2)

When attempting to evaluate the third element ofa, it will skip the first two elements and read the third, but that element is already being evaluated. This is often caused by a subtle logic error; in this case, using>= in thefilter would fix the error.

Type parameters

A

the type of the elements contained in this lazy list.

Attributes

See also

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

Companion
object
Source
LazyList.scala
Supertypes
traitLinearSeq[A]
traitLinearSeq[A]
classAbstractSeq[A]
traitSeq[A]
traitIterable[A]
classAbstractSeq[A]
traitSeq[A]
traitEquals
traitInt=>A
traitIterable[A]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
class
Source
LazyList.scala
Supertypes
classObject
traitMatchable
classAny
Show all
Self type

Base trait for immutable linear sequences that have efficienthead andtail

Base trait for immutable linear sequences that have efficienthead andtail

Attributes

Companion
object
Source
Seq.scala
Supertypes
traitLinearSeq[A]
traitSeq[A]
traitSeq[A]
traitEquals
traitInt=>A
traitIterable[A]
traitIterable[A]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classLazyList[A]
classList[A]
class::[A]
objectNil
classQueue[A]
classStream[A]
classCons[A]
objectEmpty
Show all

Attributes

Companion
trait
Source
Seq.scala
Supertypes
Self type
traitLinearSeqOps[+A,+CC <:(LinearSeq),+C <:LinearSeq[A] &LinearSeqOps[A,CC,C]] extendsSeqOps[A,CC,C],LinearSeqOps[A,CC,C]

Attributes

Source
Seq.scala
Supertypes
traitLinearSeqOps[A,CC,C]
traitSeqOps[A,CC,C]
traitSeqOps[A,CC,C]
traitIterableOps[A,CC,C]
traitIterableOnceOps[A,CC,C]
traitIterableOnce[A]
classAny
Show all
Known subtypes
classLazyList[A]
traitLinearSeq[A]
classList[A]
class::[A]
objectNil
classQueue[A]
classStream[A]
classCons[A]
objectEmpty
Show all

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

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

This class comes with two implementing case classesscala.Nil andscala.:: that implement the abstract membersisEmpty,head andtail.

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

Performance

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

Space:List implementsstructural 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 :: instanceval with42 =   42 :: mainList // also re-uses mainList, cost one :: instanceval 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 onLists 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 factoryval days = List("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")// Make a list element-by-elementval when = "AM" :: "PM" :: Nil// Pattern matchdays 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
traitLinearSeq[A]
traitLinearSeqOps[A,List,List[A]]
traitLinearSeq[A]
traitLinearSeqOps[A,List,List[A]]
classAbstractSeq[A]
traitSeq[A]
traitSeqOps[A,List,List[A]]
traitIterable[A]
classAbstractSeq[A]
traitSeq[A]
traitEquals
traitSeqOps[A,List,List[A]]
traitInt=>A
traitIterable[A]
traitIterableOps[A,List,List[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
class::[A]
objectNil

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

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

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 ashead andtail are O(n), whilelast andinit 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 ofListMap represent empty maps; they can be either created by calling the constructor directly, or by applying the functionListMap.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
traitSeqMap[K,V]
traitSeqMap[K,V]
classAbstractMap[K,V]
traitMap[K,V]
traitMapOps[K,V,ListMap,ListMap[K,V]]
traitIterable[(K,V)]
classAbstractMap[K,V]
traitMap[K,V]
traitEquals
traitMapOps[K,V,ListMap,ListMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
classAbstractIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,ListMap[K,V]]
traitIterableOnceOps[(K,V),Iterable,ListMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
objectListMap extendsMapFactory[ListMap]

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable 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 onList Maps for more information.

Companion
class
Source
ListMap.scala
Supertypes
classObject
traitMatchable
classAny
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 ashead andtail are O(n), whilelast andinit 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 ofListSet represent empty sets; they can be either created by calling the constructor directly, or by applying the functionListSet.empty.

Type parameters

A

the type of the elements contained in this list set

Attributes

Companion
object
Source
ListSet.scala
Supertypes

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable 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
Self type
ListSet.type
objectLongMap

A companion object for long maps.

A companion object for long maps.

Attributes

Companion
class
Source
LongMap.scala
Supertypes
classObject
traitMatchable
classAny
Self type
LongMap.type
sealed abstractclassLongMap[+T] extendsAbstractMap[Long,T],StrictOptimizedMapOps[Long,T,Map,LongMap[T]],Serializable

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

Specialised immutable map structure for long keys, based onFast 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
traitMap[K,+V] extendsIterable[(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
traitMapOps[K,V,Map,Map[K,V]]
traitMap[K,V]
traitEquals
traitMapOps[K,V,Map,Map[K,V]]
traitPartialFunction[K,V]
traitK=>V
traitIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,Map[K,V]]
traitIterableOnceOps[(K,V),Iterable,Map[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
Show all
objectMap extendsMapFactory[Map]

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
trait
Source
Map.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Map.type
traitMapOps[K,+V,+CC <:([X,Y] =>>MapOps[X,Y,CC,_]),+C <:MapOps[K,V,CC,C]] extendsIterableOps[(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
traitMapOps[K,V,CC,C]
traitPartialFunction[K,V]
traitK=>V
traitIterableOps[(K,V),Iterable,C]
traitIterableOnceOps[(K,V),Iterable,C]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
traitMap[K,V]
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
Show all
caseobjectNil extendsList[Nothing]

Attributes

Source
List.scala
Supertypes
traitProduct
classList[Nothing]
traitSeq[Nothing]
traitSeq[Nothing]
traitEquals
traitInt=>Nothing
classObject
traitMatchable
classAny
Show all
Self type
Nil.type
sealedclassNumericRange[T](valstart:T,valend:T,valstep:T,valisInclusive:Boolean)(implicitnum:Integral[T]) extendsAbstractSeq[T],IndexedSeq[T],IndexedSeqOps[T,IndexedSeq,IndexedSeq[T]],StrictOptimizedSeqOps[T,IndexedSeq,IndexedSeq[T]],IterableFactoryDefaults[T,IndexedSeq],Serializable

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

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

Factories for likely types includeRange.BigInt,Range.Long, andRange.BigDecimal.Range.Int exists for completeness, but theInt-basedscala.Range should be more performant.

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

Attributes

Companion
object
Source
NumericRange.scala
Supertypes
Known subtypes
classExclusive[T]
classInclusive[T]
Self type

A companion object for numeric ranges.

A companion object for numeric ranges.

Attributes

Companion
class
Source
NumericRange.scala
Supertypes
classObject
traitMatchable
classAny
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 ofLists, one containing thein elements and the other theout elements. Elements are added to thein list and removed from theout list. When theout list runs dry, the queue is pivoted by replacing theout list byin.reverse, andin byNil.

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

Attributes

See also

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

Companion
object
Source
Queue.scala
Supertypes
traitLinearSeq[A]
traitLinearSeq[A]
classAbstractSeq[A]
traitSeq[A]
traitSeqOps[A,Queue,Queue[A]]
traitIterable[A]
classAbstractSeq[A]
traitSeq[A]
traitEquals
traitSeqOps[A,Queue,Queue[A]]
traitInt=>A
traitIterable[A]
traitIterableOps[A,Queue,Queue[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

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

TheRange class represents integer values in range[start;end) with non-zero step valuestep.

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

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

Ranges that contain more thanInt.MaxValue elements can be created, but these overfull ranges have only limited capabilities. Any method that could require a collection of overInt.MaxValue length to be created, or could be asked to index beyondInt.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, uselast instead.

start

the start of this range.

step

the step for the range.

Attributes

Companion
object
Source
Range.scala
Supertypes
traitSeq[Int]
traitIterable[Int]
traitSeq[Int]
traitEquals
traitInt=>Int
traitIterable[Int]
classObject
traitMatchable
classAny
Show all
Known subtypes
classExclusive
classInclusive
Self type
objectRange

Companion object for ranges.

Companion object for ranges.

Attributes

Companion
class
Source
Range.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Range.type
traitSeq[+A] extendsIterable[A],Seq[A],SeqOps[A,Seq,Seq[A]],IterableFactoryDefaults[A,Seq]

Attributes

Companion
object
Source
Seq.scala
Supertypes
traitSeqOps[A,Seq,Seq[A]]
traitSeq[A]
traitEquals
traitSeqOps[A,Seq,Seq[A]]
traitInt=>A
traitIterable[A]
traitIterable[A]
traitIterableOps[A,Seq,Seq[A]]
traitIterableOnceOps[A,Seq,Seq[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classAbstractSeq[A]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
traitIndexedSeq[A]
traitLinearSeq[A]
Show all
objectSeq extendsDelegate[Seq]

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
trait
Source
Seq.scala
Supertypes
classDelegate[Seq]
classObject
traitMatchable
classAny
Show all
Self type
Seq.type
traitSeqMap[K,+V] extendsMap[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 theequals method forSeqMap compares key-value pairs without regard to ordering.

All behavior is defined in terms of the abstract methods inSeqMap. It is sufficient for concrete subclasses to implement those methods. Methods that return a new map, in particularremoved andupdated, 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
traitSeqMap[K,V]
traitMap[K,V]
traitMapOps[K,V,SeqMap,SeqMap[K,V]]
traitMap[K,V]
traitEquals
traitMapOps[K,V,SeqMap,SeqMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
traitIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,SeqMap[K,V]]
traitIterableOnceOps[(K,V),Iterable,SeqMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
classListMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
objectSeqMap extendsMapFactory[SeqMap]

Attributes

Companion
trait
Source
SeqMap.scala
Supertypes
classObject
traitMatchable
classAny
Self type
SeqMap.type
traitSeqOps[+A,+CC[_],+C] extendsSeqOps[A,CC,C]

Attributes

Source
Seq.scala
Supertypes
traitSeqOps[A,CC,C]
traitIterableOps[A,CC,C]
traitIterableOnceOps[A,CC,C]
traitIterableOnce[A]
classAny
Known subtypes
traitIndexedSeqOps[A,CC,C]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
traitIndexedSeq[A]
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classRange
classExclusive
classInclusive
classVector[A]
traitLinearSeqOps[A,CC,C]
classLazyList[A]
traitLinearSeq[A]
classList[A]
class::[A]
objectNil
classQueue[A]
classStream[A]
classCons[A]
objectEmpty
traitSeq[A]
classAbstractSeq[A]
traitStrictOptimizedSeqOps[A,CC,C]
Show all
traitSet[A] extendsIterable[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
traitSetOps[A,Set,Set[A]]
traitSet[A]
traitEquals
traitSetOps[A,Set,Set[A]]
traitA=>Boolean
traitIterable[A]
traitIterable[A]
traitIterableOps[A,Set,Set[A]]
traitIterableOnceOps[A,Set,Set[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classAbstractSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
traitSortedSet[A]
Show all
objectSet extendsIterableFactory[Set]

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
trait
Source
Set.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Set.type
traitSetOps[A,+CC[X],+C <:SetOps[A,CC,C]] extendsSetOps[A,CC,C]

Base trait for immutable set operations

Base trait for immutable set operations

Attributes

Source
Set.scala
Supertypes
traitSetOps[A,CC,C]
traitA=>Boolean
traitIterableOps[A,CC,C]
traitIterableOnceOps[A,CC,C]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
traitSet[A]
classAbstractSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
traitSortedSet[A]
traitSortedSetOps[A,CC,C]
traitStrictOptimizedSetOps[A,CC,C]
Show all

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

An immutable map whose key-value pairs are sorted according to anscala.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'sscala.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 factoryval 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
traitSortedMap[K,V]
traitSortedOps[K,SortedMap[K,V]]
traitMap[K,V]
traitMapOps[K,V,Map,SortedMap[K,V]]
traitMap[K,V]
traitEquals
traitMapOps[K,V,Map,SortedMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
traitIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,SortedMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
classWithDefault[K,V]
classTreeMap[K,V]

Attributes

Companion
trait
Source
SortedMap.scala
Supertypes
classObject
traitMatchable
classAny
Show all
Self type
traitSortedMapOps[K,+V,+CC <:([X,Y] =>>Map[X,Y] &SortedMapOps[X,Y,CC,_]),+C <:SortedMapOps[K,V,CC,C]] extendsMapOps[K,V,Map,C],SortedMapOps[K,V,CC,C]

Attributes

Source
SortedMap.scala
Supertypes
traitSortedMapOps[K,V,CC,C]
traitSortedOps[K,C]
traitMapOps[K,V,Map,C]
traitMapOps[K,V,Map,C]
traitPartialFunction[K,V]
traitK=>V
traitIterableOps[(K,V),Iterable,C]
traitIterableOnceOps[(K,V),Iterable,C]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
traitSortedMap[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
Self type
SortedMapOps[K,V,CC,C]

Base trait for sorted sets

Base trait for sorted sets

Attributes

Companion
object
Source
SortedSet.scala
Supertypes
traitSortedSet[A]
traitSortedOps[A,SortedSet[A]]
traitSet[A]
traitSetOps[A,Set,SortedSet[A]]
traitSet[A]
traitEquals
traitSetOps[A,Set,SortedSet[A]]
traitA=>Boolean
traitIterable[A]
traitIterable[A]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classBitSet
classBitSet1
classBitSet2
classBitSetN
classTreeSet[A]
Show all

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

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

Attributes

Source
SortedSet.scala
Supertypes
traitSortedSetOps[A,CC,C]
traitSortedOps[A,C]
traitSetOps[A,Set,C]
traitSetOps[A,Set,C]
traitA=>Boolean
traitIterableOps[A,Set,C]
traitIterableOnceOps[A,Set,C]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classBitSet
classBitSet1
classBitSet2
classBitSetN
traitSortedSet[A]
classTreeSet[A]
Show all
traitStrictOptimizedMapOps[K,+V,+CC <:([X,Y] =>>MapOps[X,Y,CC,_]),+C <:MapOps[K,V,CC,C]] extendsMapOps[K,V,CC,C],StrictOptimizedMapOps[K,V,CC,C],StrictOptimizedIterableOps[(K,V),Iterable,C]

Attributes

Source
Map.scala
Supertypes
traitStrictOptimizedMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
traitPartialFunction[K,V]
traitK=>V
traitIterableOps[(K,V),Iterable,C]
traitIterableOnceOps[(K,V),Iterable,C]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
Show all
traitStrictOptimizedSeqOps[+A,+CC[_],+C] extendsSeqOps[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
traitStrictOptimizedSeqOps[A,CC,C]
traitSeqOps[A,CC,C]
traitSeqOps[A,CC,C]
traitIterableOps[A,CC,C]
traitIterableOnceOps[A,CC,C]
traitIterableOnce[A]
classAny
Show all
Known subtypes
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classVector[A]
Show all
traitStrictOptimizedSetOps[A,+CC[X],+C <:SetOps[A,CC,C]] extendsSetOps[A,CC,C],StrictOptimizedSetOps[A,CC,C],StrictOptimizedIterableOps[A,CC,C]

Attributes

Source
Set.scala
Supertypes
traitStrictOptimizedSetOps[A,CC,C]
traitSetOps[A,CC,C]
traitSetOps[A,CC,C]
traitA=>Boolean
traitIterableOps[A,CC,C]
traitIterableOnceOps[A,CC,C]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classHashSet[A]
classListSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classTreeSet[A]
Show all
traitStrictOptimizedSortedMapOps[K,+V,+CC <:([X,Y] =>>Map[X,Y] &SortedMapOps[X,Y,CC,_]),+C <:SortedMapOps[K,V,CC,C]] extendsSortedMapOps[K,V,CC,C],StrictOptimizedSortedMapOps[K,V,CC,C],StrictOptimizedMapOps[K,V,Map,C]

Attributes

Source
SortedMap.scala
Supertypes
traitSortedMapOps[K,V,CC,C]
traitSortedMapOps[K,V,CC,C]
traitSortedOps[K,C]
traitMapOps[K,V,Map,C]
traitMapOps[K,V,Map,C]
traitPartialFunction[K,V]
traitK=>V
traitIterableOps[(K,V),Iterable,C]
traitIterableOnceOps[(K,V),Iterable,C]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all
Known subtypes
classTreeMap[K,V]

Attributes

Source
SortedSet.scala
Supertypes
traitSortedSetOps[A,CC,C]
traitSortedSetOps[A,CC,C]
traitSortedOps[A,C]
traitSetOps[A,Set,C]
traitSetOps[A,Set,C]
traitA=>Boolean
traitIterableOps[A,Set,C]
traitIterableOnceOps[A,Set,C]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classBitSet
classBitSet1
classBitSet2
classBitSetN
classTreeSet[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 typeA.

Attributes

See also

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

Example

import scala.collection.immutable.TreeMap// Make a TreeMap via the companion object factoryval 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
traitSortedMap[K,V]
traitSortedMapOps[K,V,TreeMap,TreeMap[K,V]]
traitSortedMap[K,V]
traitSortedMapOps[K,V,TreeMap,TreeMap[K,V]]
traitSortedOps[K,TreeMap[K,V]]
classAbstractMap[K,V]
traitMap[K,V]
traitMapOps[K,V,Map,TreeMap[K,V]]
traitIterable[(K,V)]
classAbstractMap[K,V]
traitMap[K,V]
traitEquals
traitMapOps[K,V,Map,TreeMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
classAbstractIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,TreeMap[K,V]]
traitIterableOnceOps[(K,V),Iterable,TreeMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

Companion
class
Source
TreeMap.scala
Supertypes
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.

TheorderingBy(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 therefresh(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
traitSeqMap[K,V]
traitSeqMap[K,V]
classAbstractMap[K,V]
traitMap[K,V]
traitMapOps[K,V,TreeSeqMap,TreeSeqMap[K,V]]
traitIterable[(K,V)]
classAbstractMap[K,V]
traitMap[K,V]
traitEquals
traitMapOps[K,V,TreeSeqMap,TreeSeqMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
classAbstractIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,TreeSeqMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all

Attributes

Companion
class
Source
TreeSeqMap.scala
Supertypes
Self 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 typeA

Attributes

See also

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

Companion
object
Source
TreeSet.scala
Supertypes
traitSortedSet[A]
traitSortedSet[A]
traitSortedOps[A,TreeSet[A]]
classAbstractSet[A]
traitSet[A]
traitSetOps[A,Set,TreeSet[A]]
traitIterable[A]
classAbstractSet[A]
traitSet[A]
traitEquals
traitSetOps[A,Set,TreeSet[A]]
traitA=>Boolean
traitIterable[A]
traitIterableOps[A,Set,TreeSet[A]]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable values.

Attributes

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

This object provides a set of operations to createIterable values.

This object provides a set of operations to createIterable 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 adata (central) array the first dimension may be up to WIDTH-2 long, inprefix1 andsuffix1 up to WIDTH, and in otherprefix andsuffix arrays up to WIDTH-1 -prefix1 andsuffix1 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
finalclassVectorBuilder[A] extendsReusableBuilder[A,Vector[A]]

Attributes

Source
Vector.scala
Supertypes
traitBuilder[A,Vector[A]]
traitGrowable[A]
traitClearable
classObject
traitMatchable
classAny
Show all

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.

UnlikeListMap,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
traitSeqMap[K,V]
traitSeqMap[K,V]
classAbstractMap[K,V]
traitMap[K,V]
traitMapOps[K,V,VectorMap,VectorMap[K,V]]
traitIterable[(K,V)]
classAbstractMap[K,V]
traitMap[K,V]
traitEquals
traitMapOps[K,V,VectorMap,VectorMap[K,V]]
traitPartialFunction[K,V]
traitK=>V
classAbstractIterable[(K,V)]
traitIterable[(K,V)]
traitIterableOps[(K,V),Iterable,VectorMap[K,V]]
traitIterableOnce[(K,V)]
classObject
traitMatchable
classAny
Show all

Attributes

Companion
class
Source
VectorMap.scala
Supertypes
Self type

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

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

The difference between this class andStringOps is that calling transformer methods such asfilter andmap will yield an object of typeWrappedString rather than aString.

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

Attributes

Companion
object
Deprecated
[Since version 2.13.0]Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only)
Source
Stream.scala
Supertypes
traitLinearSeq[A]
traitLinearSeq[A]
classAbstractSeq[A]
traitSeq[A]
traitSeqOps[A,Stream,Stream[A]]
traitIterable[A]
classAbstractSeq[A]
traitSeq[A]
traitEquals
traitSeqOps[A,Stream,Stream[A]]
traitInt=>A
traitIterable[A]
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
classCons[A]
objectEmpty
objectStream extendsSeqFactory[Stream]

Attributes

Companion
class
Deprecated
[Since version 2.13.0]Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only)
Source
Stream.scala
Supertypes
classObject
traitMatchable
classAny
Show all
Self type
Stream.type

Types

Attributes

Source
package.scala

Attributes

Source
package.scala

Deprecated types

typeDefaultMap[K,+V] =Map[K,V]

Attributes

Deprecated
[Since version 2.13.0]Use Map instead of DefaultMap
Source
package.scala
typeTraversable[+X] =Iterable[X]

Attributes

Deprecated
[Since version 2.13.0]Use Iterable instead of Traversable
Source
package.scala

Value members

Concrete fields

Attributes

Source
package.scala
valStringView:StringView.type

Attributes

Source
package.scala

Deprecated fields

Attributes

Deprecated
[Since version 2.13.0]Use Iterable instead of Traversable
Source
package.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp