package immutable
- Alphabetic
- Public
- All
Type Members
- case class :: [+A](x: A, next: List[A]) extends List[A] with Product with Serializable
-
sealed abstract
class
BitSet
extends SortedSet[Int] with collection.BitSet with SortedSetOps[Int, SortedSet, BitSet] with BitSetOps[BitSet] with StrictOptimizedIterableOps[Int, Set, BitSet] with Serializable
A class for immutable bitsets.
A class for immutable bitsets. $bitsetinfo
- Annotations
- @SerialVersionUID()
- See also
"Scala's Collection Library overview" section on
Immutable BitSets
for more information.
-
sealed
trait
HashMap
[K, +V] extends Map[K, V] with MapOps[K, V, HashMap, HashMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, HashMap[K, V]] with Serializable
This class implements immutable maps using a hash trie.
This class implements immutable maps using a hash trie.
Note: The builder of this hash map may return specialized representations for small maps.
- K
the type of the keys contained in this hash map.
- V
the type of the values associated with the keys.
- Annotations
- @SerialVersionUID()
- Version
2.8
- Since
2.3
- See also
"Scala's Collection Library overview" section on
Hash Tries
for more information.
-
sealed
trait
HashSet
[A] extends Set[A] with SetOps[A, HashSet, HashSet[A]] with StrictOptimizedIterableOps[A, HashSet, HashSet[A]] with Serializable
This class implements immutable sets using a hash trie.
This class implements immutable sets using a hash trie.
Note: The builder of this hash set may return specialized representations for small sets.
- A
the type of the elements contained in this hash set.
- Annotations
- @SerialVersionUID()
- Version
2.8
- Since
2.3
-
class
ImmutableArray
[+A] extends IndexedSeq[A] with IndexedSeqOps[A, ImmutableArray, ImmutableArray[A]] with StrictOptimizedSeqOps[A, ImmutableArray, ImmutableArray[A]]
An immutable array.
An immutable array.
Supports efficient indexed access and has a small memory footprint.
-
trait
IndexedSeq
[+A] extends Seq[A] with collection.IndexedSeq[A] with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]]
Base trait for immutable indexed sequences that have efficient
apply
andlength
-
trait
IndexedSeqOps
[+A, +CC[X] <: IndexedSeq[X], +C] extends SeqOps[A, CC, C] with collection.IndexedSeqOps[A, CC, C]
Base trait for immutable indexed Seq operations
- trait Iterable [+A] extends collection.Iterable[A] with IterableOps[A, Iterable, Iterable[A]]
- class LazyList [+A] extends LinearSeq[A] with LinearSeqOps[A, LazyList, LazyList[A]]
-
trait
LinearSeq
[+A] extends Seq[A] with collection.LinearSeq[A] with LinearSeqOps[A, LinearSeq, LinearSeq[A]]
Base trait for immutable linear sequences that have efficient
head
andtail
- trait LinearSeqOps [+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A]] extends SeqOps[A, CC, C] with collection.LinearSeqOps[A, CC, C]
-
sealed
trait
List
[+A] extends LinearSeq[A] with LinearSeqOps[A, List, List[A]] with StrictOptimizedSeqOps[A, List, List[A]] with Serializable
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
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 than
List
.$usesMutableState
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
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
- Annotations
- @SerialVersionUID()
// 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.") }
- Version
2.8
- Since
1.0
- 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.
- See also
"Scala's Collection Library overview" section on
Lists
for more information.
Example: -
sealed
class
ListMap
[K, +V] extends Map[K, V] with MapOps[K, V, ListMap, ListMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, ListMap[K, V]] with Serializable
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 whey 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
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 of
ListMap
represent empty maps; they can be either created by calling the constructor directly, or by applying the functionListMap.empty
.- K
the type of the keys contained in this list map
- V
the type of the values associated with the keys
- Annotations
- @SerialVersionUID()
- Version
2.0, 01/01/2007
- Since
1
-
sealed
class
ListSet
[A] extends Set[A] with SetOps[A, ListSet, ListSet[A]] with StrictOptimizedIterableOps[A, ListSet, ListSet[A]] with Serializable
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 whey 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
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 of
ListSet
represent empty sets; they can be either created by calling the constructor directly, or by applying the functionListSet.empty
.- A
the type of the elements contained in this list set
- Annotations
- @SerialVersionUID()
- Version
1.0, 09/07/2003
- Since
1
-
trait
Map
[K, +V] extends Iterable[(K, V)] with collection.Map[K, V] with MapOps[K, V, Map, Map[K, V]]
Base type of immutable Maps
-
trait
MapOps
[K, +V, +CC[X, +Y] <: Map[X, Y] with MapOps[X, Y, CC, _], +C <: Map[K, V]] extends IterableOps[(K, V), Iterable, C] with collection.MapOps[K, V, CC, C]
Base trait of immutable Maps implementations
-
final
class
NumericRange
[T] extends IndexedSeq[T] with IndexedSeqOps[T, IndexedSeq, IndexedSeq[T]] with StrictOptimizedSeqOps[T, IndexedSeq, IndexedSeq[T]] with 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 include
Range.BigInt
,Range.Long
, andRange.BigDecimal
.Range.Int
exists for completeness, but theInt
-basedscala.Range
should be more performant.val r1 = new Range(0, 100, 1) val veryBig = Int.MaxValue.toLong + 1 val r2 = Range.Long(veryBig, veryBig + 100, 1) assert(r1 sameElements r2.map(_ - veryBig))
-
final
class
Range
extends IndexedSeq[Int] with IndexedSeqOps[Int, IndexedSeq, IndexedSeq[Int]] with StrictOptimizedSeqOps[Int, IndexedSeq, IndexedSeq[Int]] with Serializable
The
Range
class represents integer values in range [start;end) with non-zero step valuestep
.The
Range
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 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 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.- Annotations
- @SerialVersionUID()
- trait Seq [+A] extends Iterable[A] with collection.Seq[A] with SeqOps[A, Seq, Seq[A]]
- trait SeqOps [+A, +CC[_], +C] extends collection.SeqOps[A, CC, C]
-
trait
Set
[A] extends Iterable[A] with collection.Set[A] with SetOps[A, Set, Set[A]]
Base trait for immutable set collections
-
trait
SetOps
[A, +CC[X], +C <: Set[A] with SetOps[A, Set, C]] extends collection.SetOps[A, CC, C]
Base trait for immutable set operations
- trait SortedMap [K, +V] extends Map[K, V] with collection.SortedMap[K, V] with SortedMapOps[K, V, SortedMap, SortedMap[K, V]]
- trait SortedMapOps [K, +V, +CC[X, +Y] <: SortedMap[X, Y] with SortedMapOps[X, Y, CC, _], +C <: SortedMap[K, V]] extends MapOps[K, V, Map, C] with collection.SortedMapOps[K, V, CC, C]
-
trait
SortedSet
[A] extends Set[A] with collection.SortedSet[A] with SortedSetOps[A, SortedSet, SortedSet[A]]
Base trait for sorted sets
- trait SortedSetOps [A, +CC[X] <: SortedSet[X] with SortedSetOps[X, CC, _], +C <: SortedSet[A] with SortedSetOps[A, SortedSet, C]] extends SetOps[A, Set, C] with collection.SortedSetOps[A, CC, C]
-
trait
StrictOptimizedSeqOps
[+A, +CC[_], +C] extends SeqOps[A, CC, C] with StrictOptimizedIterableOps[A, CC, C]
Trait that overrides operations to take advantage of strict builders.
-
final
class
TreeMap
[K, +V] extends SortedMap[K, V] with SortedMapOps[K, V, TreeMap, TreeMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, TreeMap[K, V]] with Serializable
This class implements immutable maps using a tree.
This class implements immutable maps using a tree.
- K
the type of the keys contained in this tree map.
- V
the type of the values associated with the keys.
- Annotations
- @SerialVersionUID()
- Version
1.1, 03/05/2004
- Since
1
- See also
"Scala's Collection Library overview" section on
Red-Black Trees
for more information.
-
final
class
TreeSet
[A] extends SortedSet[A] with SortedSetOps[A, TreeSet, TreeSet[A]] with StrictOptimizedIterableOps[A, Set, TreeSet[A]]
This class implements immutable sorted sets using a tree.
This class implements immutable sorted sets using a tree.
- A
the type of the elements contained in this tree set
- Version
2.0, 02/01/2007
- Since
1
- See also
"Scala's Collection Library overview" section on
Red-Black Trees
for more information.
-
final
class
Vector
[+A] extends IndexedSeq[A] with IndexedSeqOps[A, Vector, Vector[A]] with StrictOptimizedSeqOps[A, Vector, Vector[A]] with VectorPointer[A] with Serializable
Vector is a general-purpose, immutable data structure.
Vector is a general-purpose, immutable data structure. It provides random access and updates in effectively constant time, as well as very fast append and prepend. 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. It is backed by a little endian bit-mapped vector trie with a branching factor of 32. Locality is very good, but not contiguous, which is good for very large sequences.
$usesMutableState
- A
the element type
- Annotations
- @SerialVersionUID()
- See also
"Scala's Collection Library overview" section on
Vectors
for more information.
-
final
class
VectorBuilder
[A] extends ReusableBuilder[A, Vector[A]] with VectorPointer[A]
A class to build instances of
Vector
.A class to build instances of
Vector
. This builder is reusable. - class VectorIterator [+A] extends Iterator[A] with VectorPointer[A]
Value Members
- object BitSet extends SpecificIterableFactory[Int, BitSet] with Serializable
- object HashMap extends MapFactory[HashMap] with Serializable
- object HashSet extends IterableFactory[HashSet] with Serializable
- object ImmutableArray extends IterableFactory[ImmutableArray]
- object IndexedSeq extends Delegate[IndexedSeq]
- object LazyList extends IterableFactory[LazyList]
- object List extends IterableFactory[List] with Serializable
-
object
ListMap
extends MapFactory[ListMap] with Serializable
$factoryInfo
$factoryInfo
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.
- Since
1
- See also
"Scala's Collection Library overview" section on
List Maps
for more information.
-
object
ListSet
extends IterableFactory[ListSet] with Serializable
$factoryInfo
$factoryInfo
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.
- Since
1
- object Map extends Delegate[Map]
- object Nil extends List[Nothing] with Product with Serializable
-
object
NumericRange
extends Serializable
A companion object for numeric ranges.
- object Range extends Serializable
- object Seq extends Delegate[Seq]
- object Set extends Delegate[Set]
- object SortedSet extends Delegate[SortedSet]
-
object
TreeMap
extends SortedMapFactory[TreeMap] with Serializable
$factoryInfo
- object TreeSet extends SortedIterableFactory[TreeSet]
-
object
Vector
extends IterableFactory[Vector] with Serializable
Companion object to the Vector class