package mutable
- Alphabetic
- By Inheritance
- mutable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract class AbstractBuffer[A] extends AbstractSeq[A] with Buffer[A]
Explicit instantiation of the
Buffer
trait to reduce class file size in subclasses. - abstract class AbstractIterable[A] extends collection.AbstractIterable[A] with Iterable[A]
Explicit instantiation of the
Iterable
trait to reduce class file size in subclasses. - abstract class AbstractMap[K, V] extends collection.AbstractMap[K, V] with Map[K, V]
Explicit instantiation of the
Map
trait to reduce class file size in subclasses. - abstract class AbstractSeq[A] extends collection.AbstractSeq[A] with Seq[A]
Explicit instantiation of the
Seq
trait to reduce class file size in subclasses. - abstract class AbstractSet[A] extends collection.AbstractSet[A] with Set[A]
Explicit instantiation of the
Set
trait to reduce class file size in subclasses. - class AnyRefMap[K <: AnyRef, V] extends AbstractMap[K, V] with MapOps[K, V, Map, AnyRefMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, AnyRefMap[K, V]] with Serializable
This class implements mutable maps with
AnyRef
keys based on a hash table with open addressing.This class implements mutable maps with
AnyRef
keys based on a hash table with open addressing.Basic map operations on single entries, including
contains
andget
, are typically significantly faster withAnyRefMap
than HashMap. Note that numbers and characters are not handled specially in AnyRefMap; only plainequals
andhashCode
are used in comparisons.Methods that traverse or regenerate the map, including
foreach
andmap
, are not in general faster than withHashMap
. The methodsforeachKey
,foreachValue
,mapValuesNow
, andtransformValues
are, however, faster than alternative ways to achieve the same functionality.Maps with open addressing may become less efficient at lookup after repeated addition/removal of elements. Although
AnyRefMap
makes a decent attempt to remain efficient regardless, callingrepack
on a map that will no longer have elements removed but will be used heavily may save both time and storage space.This map is not intended to contain more than 229 entries (approximately 500 million). The maximum capacity is 230, but performance will degrade rapidly as 230 is approached.
- class ArrayBuffer[A] extends AbstractBuffer[A] with IndexedBuffer[A] with IndexedSeqOps[A, ArrayBuffer, ArrayBuffer[A]] with StrictOptimizedSeqOps[A, ArrayBuffer, ArrayBuffer[A]] with IterableFactoryDefaults[A, ArrayBuffer] with DefaultSerializable
An implementation of the
Buffer
class using an array to represent the assembled sequence internally.An implementation of the
Buffer
class using an array to represent the assembled sequence internally. Append, update and random access take constant time (amortized time). Prepends and removes are linear in the buffer size.- A
the type of this arraybuffer's elements.
- Annotations
- @SerialVersionUID()
- See also
"Scala's Collection Library overview" section on
Array Buffers
for more information.
- final class ArrayBufferView[A] extends AbstractIndexedSeqView[A]
- sealed abstract class ArrayBuilder[T] extends ReusableBuilder[T, Array[T]] with Serializable
A builder class for arrays.
A builder class for arrays.
- T
the type of the elements for the builder.
- Annotations
- @SerialVersionUID()
- class ArrayDeque[A] extends AbstractBuffer[A] with IndexedBuffer[A] with IndexedSeqOps[A, ArrayDeque, ArrayDeque[A]] with StrictOptimizedSeqOps[A, ArrayDeque, ArrayDeque[A]] with IterableFactoryDefaults[A, ArrayDeque] with ArrayDequeOps[A, ArrayDeque, ArrayDeque[A]] with Cloneable[ArrayDeque[A]] with DefaultSerializable
An implementation of a double-ended queue that internally uses a resizable circular buffer.
An implementation of a double-ended queue that internally uses a resizable circular buffer.
Append, prepend, removeHead, removeLast and random-access (indexed-lookup and indexed-replacement) take amortized constant time. In general, removals and insertions at i-th index are O(min(i, n-i)) and thus insertions and removals from end/beginning are fast.
- A
the type of this ArrayDeque's elements.
- Note
Subclasses must override the
ofArray
protected method to return a more specific type.
- trait ArrayDequeOps[A, +CC[_], +C <: AnyRef] extends StrictOptimizedSeqOps[A, CC, C]
- sealed abstract class ArraySeq[T] extends AbstractSeq[T] with IndexedSeq[T] with IndexedSeqOps[T, ArraySeq, ArraySeq[T]] with StrictOptimizedSeqOps[T, ArraySeq, ArraySeq[T]] with Serializable
A collection representing
Array[T]
.A collection representing
Array[T]
. UnlikeArrayBuffer
it is always backed by the same underlyingArray
, therefore it is not growable or shrinkable.- T
type of the elements in this wrapped array.
- Annotations
- @SerialVersionUID()
- class BitSet extends AbstractSet[Int] with SortedSet[Int] with SortedSetOps[Int, SortedSet, BitSet] with StrictOptimizedIterableOps[Int, Set, BitSet] with StrictOptimizedSortedSetOps[Int, SortedSet, BitSet] with collection.BitSet with BitSetOps[BitSet] with Serializable
A class for mutable bitsets.
A class for mutable 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.
- See also
"Scala's Collection Library overview" section on
Mutable Bitsets
for more information.
- trait Buffer[A] extends Seq[A] with SeqOps[A, Buffer, Buffer[A]] with Growable[A] with Shrinkable[A] with IterableFactoryDefaults[A, Buffer]
A
Buffer
is a growable and shrinkableSeq
. - trait Builder[-A, +To] extends Growable[A]
Base trait for collection builders.
Base trait for collection builders.
After calling
result()
the behavior of a Builder (which is not also a scala.collection.mutable.ReusableBuilder) is undefined. No further methods should be called. It is common for mutable collections to be their own non-reusable Builder, in which caseresult()
simply returnsthis
.- See also
scala.collection.mutable.ReusableBuilder for Builders which can be reused after calling
result()
- trait Clearable extends AnyRef
This trait forms part of collections that can be cleared with a clear() call.
- trait Cloneable[+C <: AnyRef] extends scala.Cloneable
A trait for cloneable collections.
A trait for cloneable collections.
- C
Type of the collection, covariant and with reference types as upperbound.
- final class CollisionProofHashMap[K, V] extends AbstractMap[K, V] with MapOps[K, V, Map, CollisionProofHashMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, CollisionProofHashMap[K, V]] with StrictOptimizedMapOps[K, V, Map, CollisionProofHashMap[K, V]]
This class implements mutable maps using a hashtable with red-black trees in the buckets for good worst-case performance on hash collisions.
This class implements mutable maps using a hashtable with red-black trees in the buckets for good worst-case performance on hash collisions. An
Ordering
is required for the element type. Equality as determined by theOrdering
has to be consistent withequals
andhashCode
. Universal equality of numeric types is not supported (similar toAnyRefMap
).- See also
"Scala's Collection Library overview" section on
Hash Tables
for more information.
- trait Growable[-A] extends Clearable
This trait forms part of collections that can be augmented using a
+=
operator and that can be cleared of all elements using aclear
method. - class GrowableBuilder[Elem, To <: Growable[Elem]] extends Builder[Elem, To]
The canonical builder for collections that are growable, i.e.
The canonical builder for collections that are growable, i.e. that support an efficient
+=
method which adds an element to the collection.GrowableBuilders can produce only a single instance of the collection they are growing.
- class HashMap[K, V] extends AbstractMap[K, V] with MapOps[K, V, HashMap, HashMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, HashMap[K, V]] with StrictOptimizedMapOps[K, V, HashMap, HashMap[K, V]] with MapFactoryDefaults[K, V, HashMap, Iterable] with Serializable
This class implements mutable maps using a hashtable.
This class implements mutable maps using a hashtable.
- K
the type of the keys contained in this hash map.
- V
the type of the values assigned to keys in this hash map.
- Annotations
- @deprecatedInheritance()
- See also
"Scala's Collection Library overview" section on
Hash Tables
for more information.
- final class HashSet[A] extends AbstractSet[A] with SetOps[A, HashSet, HashSet[A]] with StrictOptimizedIterableOps[A, HashSet, HashSet[A]] with IterableFactoryDefaults[A, HashSet] with Serializable
This class implements mutable sets using a hashtable.
This class implements mutable sets using a hashtable.
- See also
"Scala's Collection Library overview" section on
Hash Tables
for more information.
- abstract class ImmutableBuilder[-A, C <: IterableOnce[_]] extends ReusableBuilder[A, C]
Reusable builder for immutable collections
- trait IndexedBuffer[A] extends IndexedSeq[A] with IndexedSeqOps[A, IndexedBuffer, IndexedBuffer[A]] with Buffer[A] with IterableFactoryDefaults[A, IndexedBuffer]
- trait IndexedSeq[T] extends Seq[T] with collection.IndexedSeq[T] with IndexedSeqOps[T, IndexedSeq, IndexedSeq[T]] with IterableFactoryDefaults[T, IndexedSeq]
- trait IndexedSeqOps[A, +CC[_], +C <: AnyRef] extends collection.IndexedSeqOps[A, CC, C] with SeqOps[A, CC, C]
- trait Iterable[A] extends collection.Iterable[A] with IterableOps[A, Iterable, Iterable[A]] with IterableFactoryDefaults[A, Iterable]
- class LinkedHashMap[K, V] extends AbstractMap[K, V] with SeqMap[K, V] with MapOps[K, V, LinkedHashMap, LinkedHashMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, LinkedHashMap[K, V]] with StrictOptimizedMapOps[K, V, LinkedHashMap, LinkedHashMap[K, V]] with MapFactoryDefaults[K, V, LinkedHashMap, Iterable] with DefaultSerializable
This class implements mutable maps using a hashtable.
This class implements mutable maps using a hashtable. The iterator and all traversal methods of this class visit elements in the order they were inserted.
- K
the type of the keys contained in this hash map.
- V
the type of the values assigned to keys in this hash map.
- Annotations
- @deprecatedInheritance()
- class LinkedHashSet[A] extends AbstractSet[A] with SetOps[A, LinkedHashSet, LinkedHashSet[A]] with StrictOptimizedIterableOps[A, LinkedHashSet, LinkedHashSet[A]] with IterableFactoryDefaults[A, LinkedHashSet] with DefaultSerializable
This class implements mutable sets using a hashtable.
This class implements mutable sets using a hashtable. The iterator and all traversal methods of this class visit elements in the order they were inserted.
- A
the type of the elements contained in this set.
- Annotations
- @deprecatedInheritance()
- class ListBuffer[A] extends AbstractBuffer[A] with SeqOps[A, ListBuffer, ListBuffer[A]] with StrictOptimizedSeqOps[A, ListBuffer, ListBuffer[A]] with ReusableBuilder[A, immutable.List[A]] with IterableFactoryDefaults[A, ListBuffer] with DefaultSerializable
A
Buffer
implementation backed by a list.A
Buffer
implementation backed by a list. It provides constant time prepend and append. Most other operations are linear.- A
the type of this list buffer's elements.
- Annotations
- @SerialVersionUID()
- See also
"Scala's Collection Library overview" section on
List Buffers
for more information.
- final class LongMap[V] extends AbstractMap[Long, V] with MapOps[Long, V, Map, LongMap[V]] with StrictOptimizedIterableOps[(Long, V), Iterable, LongMap[V]] with Serializable
This class implements mutable maps with
Long
keys based on a hash table with open addressing.This class implements mutable maps with
Long
keys based on a hash table with open addressing.Basic map operations on single entries, including
contains
andget
, are typically substantially faster withLongMap
than HashMap. Methods that act on the whole map, includingforeach
andmap
are not in general expected to be faster than with a generic map, save for those that take particular advantage of the internal structure of the map:foreachKey
,foreachValue
,mapValuesNow
, andtransformValues
.Maps with open addressing may become less efficient at lookup after repeated addition/removal of elements. Although
LongMap
makes a decent attempt to remain efficient regardless, callingrepack
on a map that will no longer have elements removed but will be used heavily may save both time and storage space.This map is not intended to contain more than 229 entries (approximately 500 million). The maximum capacity is 230, but performance will degrade rapidly as 2^30 is approached.
- trait Map[K, V] extends Iterable[(K, V)] with collection.Map[K, V] with MapOps[K, V, Map, Map[K, V]] with Growable[(K, V)] with Shrinkable[K] with MapFactoryDefaults[K, V, Map, Iterable]
Base type of mutable Maps
- trait MapOps[K, V, +CC[X, Y] <: MapOps[X, Y, CC, _], +C <: MapOps[K, V, CC, C]] extends IterableOps[(K, V), Iterable, C] with collection.MapOps[K, V, CC, C] with Cloneable[C] with Builder[(K, V), C] with Growable[(K, V)] with Shrinkable[K]
- sealed class PriorityQueue[A] extends AbstractIterable[A] with Iterable[A] with IterableOps[A, Iterable, PriorityQueue[A]] with StrictOptimizedIterableOps[A, Iterable, PriorityQueue[A]] with Builder[A, PriorityQueue[A]] with Cloneable[PriorityQueue[A]] with Growable[A] with Serializable
A heap-based priority queue.
A heap-based priority queue.
To prioritize elements of type
A
there must be an implicitOrdering[A]
available at creation. Elements are retrieved in priority order by using dequeue or dequeueAll.If multiple elements have the same priority as determined by the ordering for this
PriorityQueue
, no guarantees are made regarding the order in which those elements are returned bydequeue
ordequeueAll
. In particular, that means this class does not guarantee first-in-first-out behavior, as may be incorrectly inferred from the fact that this data structure is called a "queue".Only the
dequeue
anddequeueAll
methods will return elements in priority order (while removing elements from the heap). Standard collection methods such asdrop
,iterator
,toList
andtoString
use an arbitrary iteration order: they will traverse the heap or remove elements in whichever order seems most convenient.Therefore, printing a
PriorityQueue
will not show elements in priority order, though the highest-priority element will be printed first. To print the elements in order, it's necessary todequeue
them. To do this non-destructively, duplicate thePriorityQueue
first; theclone
method is a suitable way to obtain a disposable copy.Client keys are assumed to be immutable. Mutating keys may violate the invariant of the underlying heap-ordered tree. Note that clone does not rebuild the underlying tree.
scala> val pq = collection.mutable.PriorityQueue(1, 2, 5, 3, 7) val pq: scala.collection.mutable.PriorityQueue[Int] = PriorityQueue(7, 3, 5, 1, 2) scala> pq.toList // also not in order val res0: List[Int] = List(7, 3, 5, 1, 2) scala> pq.clone.dequeueAll val res1: Seq[Int] = ArraySeq(7, 5, 3, 2, 1)
- A
type of the elements in this priority queue.
- class Queue[A] extends ArrayDeque[A] with IndexedSeqOps[A, Queue, Queue[A]] with StrictOptimizedSeqOps[A, Queue, Queue[A]] with IterableFactoryDefaults[A, Queue] with ArrayDequeOps[A, Queue, Queue[A]] with Cloneable[Queue[A]] with DefaultSerializable
Queue
objects implement data structures that allow to insert and retrieve elements in a first-in-first-out (FIFO) manner. - trait ReusableBuilder[-Elem, +To] extends Builder[Elem, To]
ReusableBuilder
is a marker trait that indicates that aBuilder
can be reused to build more than one instance of a collection.ReusableBuilder
is a marker trait that indicates that aBuilder
can be reused to build more than one instance of a collection. In particular, callingresult()
followed byclear()
will produce a collection and reset the builder to begin building a new collection of the same type.In general no method other than
clear()
may be called afterresult()
. It is up to subclasses to implement and to document other allowed sequences of operations (e.g. calling other methods afterresult()
in order to obtain different snapshots of a collection under construction).- Elem
the type of elements that get added to the builder.
- To
the type of collection that it produced.
- trait Seq[A] extends Iterable[A] with collection.Seq[A] with SeqOps[A, Seq, Seq[A]] with IterableFactoryDefaults[A, Seq]
- trait SeqMap[K, V] extends Map[K, V] with collection.SeqMap[K, V] with MapOps[K, V, SeqMap, SeqMap[K, V]] with MapFactoryDefaults[K, V, SeqMap, Iterable]
A generic trait for ordered mutable maps.
A generic trait for ordered mutable maps. Concrete classes have to provide functionality for the abstract methods in
SeqMap
.Note that when checking for equality SeqMap does not take into account ordering.
- 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.
- trait SeqOps[A, +CC[_], +C <: AnyRef] extends collection.SeqOps[A, CC, C] with Cloneable[C]
- trait Set[A] extends Iterable[A] with collection.Set[A] with SetOps[A, Set, Set[A]] with IterableFactoryDefaults[A, Set]
Base trait for mutable sets
- trait SetOps[A, +CC[X], +C <: SetOps[A, CC, C]] extends collection.SetOps[A, CC, C] with IterableOps[A, CC, C] with Cloneable[C] with Builder[A, C] with Growable[A] with Shrinkable[A]
- trait Shrinkable[-A] extends AnyRef
This trait forms part of collections that can be reduced using a
-=
operator. - trait SortedMap[K, V] extends collection.SortedMap[K, V] with Map[K, V] with SortedMapOps[K, V, SortedMap, SortedMap[K, V]] with SortedMapFactoryDefaults[K, V, SortedMap, Iterable, Map]
Base type for mutable sorted map collections
- trait SortedMapOps[K, V, +CC[X, Y] <: Map[X, Y] with SortedMapOps[X, Y, CC, _], +C <: SortedMapOps[K, V, CC, C]] extends collection.SortedMapOps[K, V, CC, C] with MapOps[K, V, Map, C]
- trait SortedSet[A] extends Set[A] with collection.SortedSet[A] with SortedSetOps[A, SortedSet, SortedSet[A]] with SortedSetFactoryDefaults[A, SortedSet, Set]
Base type for mutable sorted set collections
- trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]] extends SetOps[A, Set, C] with collection.SortedSetOps[A, CC, C]
- class Stack[A] extends ArrayDeque[A] with IndexedSeqOps[A, Stack, Stack[A]] with StrictOptimizedSeqOps[A, Stack, Stack[A]] with IterableFactoryDefaults[A, Stack] with ArrayDequeOps[A, Stack, Stack[A]] with Cloneable[Stack[A]] with DefaultSerializable
A stack implements a data structure which allows to store and retrieve objects in a last-in-first-out (LIFO) fashion.
A stack implements a data structure which allows to store and retrieve objects in a last-in-first-out (LIFO) fashion.
Note that operations which consume and produce iterables preserve order, rather than reversing it (as would be expected from building a new stack by pushing an element at a time).
- A
type of the elements contained in this stack.
- Annotations
- @migration
- Migration
(Changed in version 2.13.0) Stack is now based on an ArrayDeque instead of a linked list
- final class StringBuilder extends AbstractSeq[Char] with ReusableBuilder[Char, String] with IndexedSeq[Char] with IndexedSeqOps[Char, IndexedSeq, StringBuilder] with IterableFactoryDefaults[Char, IndexedSeq] with CharSequence with Serializable
A builder of
String
which is also a mutable sequence of characters.A builder of
String
which is also a mutable sequence of characters.This class provides an API mostly compatible with
java.lang.StringBuilder
, except where there are conflicts with the Scala collections API, such as thereverse
method: reverse produces a newStringBuilder
, and reverseInPlace mutates this builder.Mutating operations return either
this.type
, i.e., the current builder, orUnit
.Other methods extract data or information from the builder without mutating it.
The distinction is also reflected in naming conventions used by collections, such as
append
, which mutates, andappended
, which does not, orreverse
, which does not mutate, andreverseInPlace
, which does.The
String
result may be obtained using eitherresult()
ortoString
.This Builder can be reused after calling
result()
without an intermediate call toclear()
in order to build multiple related results.- Annotations
- @SerialVersionUID()
- See also
"Scala's Collection Library overview" section on
StringBuilders
for more information.
- sealed class TreeMap[K, V] extends AbstractMap[K, V] with SortedMap[K, V] with SortedMapOps[K, V, TreeMap, TreeMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, TreeMap[K, V]] with StrictOptimizedMapOps[K, V, Map, TreeMap[K, V]] with StrictOptimizedSortedMapOps[K, V, TreeMap, TreeMap[K, V]] with SortedMapFactoryDefaults[K, V, TreeMap, Iterable, Map] with DefaultSerializable
A mutable sorted map implemented using a mutable red-black tree as underlying data structure.
A mutable sorted map implemented using a mutable red-black tree as underlying data structure.
- K
the type of the keys contained in this tree map.
- V
the type of the values associated with the keys.
- sealed class TreeSet[A] extends AbstractSet[A] with SortedSet[A] with SortedSetOps[A, TreeSet, TreeSet[A]] with StrictOptimizedIterableOps[A, Set, TreeSet[A]] with StrictOptimizedSortedSetOps[A, TreeSet, TreeSet[A]] with SortedSetFactoryDefaults[A, TreeSet, Set] with DefaultSerializable
A mutable sorted set implemented using a mutable red-black tree as underlying data structure.
A mutable sorted set implemented using a mutable red-black tree as underlying data structure.
- A
the type of the keys contained in this tree set.
- sealed class UnrolledBuffer[T] extends AbstractBuffer[T] with Buffer[T] with Seq[T] with SeqOps[T, UnrolledBuffer, UnrolledBuffer[T]] with StrictOptimizedSeqOps[T, UnrolledBuffer, UnrolledBuffer[T]] with EvidenceIterableFactoryDefaults[T, UnrolledBuffer, ClassTag] with Builder[T, UnrolledBuffer[T]] with DefaultSerializable
A buffer that stores elements in an unrolled linked list.
A buffer that stores elements in an unrolled linked list.
Unrolled linked lists store elements in linked fixed size arrays.
Unrolled buffers retain locality and low memory overhead properties of array buffers, but offer much more efficient element addition, since they never reallocate and copy the internal array.
However, they provide
O(n/m)
complexity random access, wheren
is the number of elements, andm
the size of internal array chunks.Ideal to use when:
- elements are added to the buffer and then all of the elements are traversed sequentially
- two unrolled buffers need to be concatenated (see
concat
)
Better than singly linked lists for random access, but should still be avoided for such a purpose.
- Annotations
- @SerialVersionUID()
- class WeakHashMap[K, V] extends JMapWrapper[K, V] with JMapWrapperLike[K, V, WeakHashMap, WeakHashMap[K, V]] with MapFactoryDefaults[K, V, WeakHashMap, Iterable]
A hash map with references to entries which are weakly reachable.
A hash map with references to entries which are weakly reachable. Entries are removed from this map when the key is no longer (strongly) referenced. This class wraps
java.util.WeakHashMap
.- K
type of keys contained in this map
- V
type of values associated with the keys
- Annotations
- @SerialVersionUID()
- See also
"Scala's Collection Library overview" section on
Weak Hash Maps
for more information.
Deprecated Type Members
- type ArrayStack[X] = Stack[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use Stack instead of ArrayStack; it now uses an array-based implementation
- type GrowingBuilder[Elem, To <: Growable[Elem]] = GrowableBuilder[Elem, To]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) GrowingBuilder has been renamed to GrowableBuilder
- type IndexedOptimizedBuffer[A] = IndexedBuffer[A]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) IndexedOptimizedBuffer has been renamed to IndexedBuffer
- type IndexedOptimizedSeq[A] = IndexedSeq[A]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) IndexedOptimizedSeq has been renamed to IndexedSeq
- type LinearSeq[X] = Seq[X] with collection.LinearSeq[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) mutable.LinearSeq has been removed; use LinearSeq with mutable.Seq instead
- class ListMap[K, V] extends AbstractMap[K, V] with MapOps[K, V, ListMap, ListMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, ListMap[K, V]] with StrictOptimizedMapOps[K, V, ListMap, ListMap[K, V]] with MapFactoryDefaults[K, V, ListMap, Iterable] with DefaultSerializable
A simple mutable map backed by a list, so it preserves insertion order.
A simple mutable map backed by a list, so it preserves insertion order.
- K
the type of the keys contained in this list map.
- V
the type of the values assigned to keys in this list map.
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use an immutable.ListMap assigned to a var instead of mutable.ListMap
- trait MultiMap[K, V] extends Map[K, Set[V]]
A trait for mutable maps with multiple values assigned to a key.
A trait for mutable maps with multiple values assigned to a key.
This class is typically used as a mixin. It turns maps which map
K
toSet[V]
objects into multimaps that mapK
toV
objects.- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use a scala.collection.mutable.MultiDict in the scala-collection-contrib module
// first import all necessary types from package `collection.mutable` import collection.mutable.{ HashMap, MultiMap, Set } // to create a `MultiMap` the easiest way is to mixin it into a normal // `Map` instance val mm = new HashMap[Int, Set[String]] with MultiMap[Int, String] // to add key-value pairs to a multimap it is important to use // the method `addBinding` because standard methods like `+` will // overwrite the complete key-value pair instead of adding the // value to the existing key mm.addBinding(1, "a") mm.addBinding(2, "b") mm.addBinding(1, "c") // mm now contains `Map(2 -> Set(b), 1 -> Set(c, a))` // to check if the multimap contains a value there is method // `entryExists`, which allows to traverse the including set mm.entryExists(1, _ == "a") == true mm.entryExists(1, _ == "b") == false mm.entryExists(2, _ == "b") == true // to remove a previous added value there is the method `removeBinding` mm.removeBinding(1, "a") mm.entryExists(1, _ == "a") == false
Example: - class OpenHashMap[Key, Value] extends AbstractMap[Key, Value] with MapOps[Key, Value, OpenHashMap, OpenHashMap[Key, Value]] with StrictOptimizedIterableOps[(Key, Value), Iterable, OpenHashMap[Key, Value]] with MapFactoryDefaults[Key, Value, OpenHashMap, Iterable] with DefaultSerializable
A mutable hash map based on an open addressing method.
A mutable hash map based on an open addressing method. The precise scheme is undefined, but it should make a reasonable effort to ensure that an insert with consecutive hash codes is not unnecessarily penalised. In particular, mappings of consecutive integer keys should work without significant performance loss.
- Key
type of the keys in this map.
- Value
type of the values in this map.
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use HashMap or one of the specialized versions (LongMap, AnyRefMap) instead of OpenHashMap
- type Traversable[X] = Iterable[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use Iterable instead of Traversable
- type WrappedArray[X] = ArraySeq[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use ArraySeq instead of WrappedArray; it can represent both, boxed and unboxed arrays
Value Members
- object AnyRefMap extends java.io.Serializable
- object ArrayBuffer extends StrictOptimizedSeqFactory[ArrayBuffer]
Factory object for the
ArrayBuffer
class.Factory object for the
ArrayBuffer
class.This object provides a set of operations to create
mutable.ArrayBuffer
values.- Annotations
- @SerialVersionUID()
- object ArrayBuilder extends java.io.Serializable
A companion object for array builders.
- object ArrayDeque extends StrictOptimizedSeqFactory[ArrayDeque]
This object provides a set of operations to create
ArrayDeque
values.This object provides a set of operations to create
ArrayDeque
values.- Annotations
- @SerialVersionUID()
- object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq]
A companion object used to create instances of
ArraySeq
.A companion object used to create instances of
ArraySeq
.- Annotations
- @SerialVersionUID()
- object BitSet extends SpecificIterableFactory[Int, BitSet] with java.io.Serializable
- Annotations
- @SerialVersionUID()
- object Buffer extends Delegate[Buffer]
- Annotations
- @SerialVersionUID()
- object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap]
This object provides a set of operations to create
mutable.CollisionProofHashMap
values.This object provides a set of operations to create
mutable.CollisionProofHashMap
values.- Annotations
- @SerialVersionUID()
- object Growable
- object HashMap extends MapFactory[HashMap]
This object provides a set of operations to create
mutable.HashMap
values.This object provides a set of operations to create
mutable.HashMap
values.- Annotations
- @SerialVersionUID()
- object HashSet extends IterableFactory[HashSet]
This object provides a set of operations to create
mutable.HashSet
values.This object provides a set of operations to create
mutable.HashSet
values.- Annotations
- @SerialVersionUID()
- object IndexedBuffer extends Delegate[IndexedBuffer]
- Annotations
- @SerialVersionUID()
- object IndexedSeq extends Delegate[IndexedSeq]
- Annotations
- @SerialVersionUID()
- object Iterable extends Delegate[Iterable]
This object provides a set of operations to create
mutable.Iterable
values.This object provides a set of operations to create
mutable.Iterable
values.- Annotations
- @SerialVersionUID()
- object LinkedHashMap extends MapFactory[LinkedHashMap]
This object provides a set of operations to create
LinkedHashMap
values.This object provides a set of operations to create
LinkedHashMap
values.- Annotations
- @SerialVersionUID()
- object LinkedHashSet extends IterableFactory[LinkedHashSet]
This object provides a set of operations to create
LinkedHashSet
values.This object provides a set of operations to create
LinkedHashSet
values.- Annotations
- @SerialVersionUID()
- object ListBuffer extends StrictOptimizedSeqFactory[ListBuffer]
- Annotations
- @SerialVersionUID()
- object LongMap extends java.io.Serializable
- object Map extends Delegate[Map]
This object provides a set of operations to create
mutable.Map
values.This object provides a set of operations to create
mutable.Map
values.- Annotations
- @SerialVersionUID()
- object PriorityQueue extends SortedIterableFactory[PriorityQueue]
- Annotations
- @SerialVersionUID()
- object Queue extends StrictOptimizedSeqFactory[Queue]
This object provides a set of operations to create
Queue
values.This object provides a set of operations to create
Queue
values.- Annotations
- @SerialVersionUID()
- object Seq extends Delegate[Seq]
This object provides a set of operations to create
mutable.Seq
values.This object provides a set of operations to create
mutable.Seq
values.- Annotations
- @SerialVersionUID()
- object SeqMap extends Delegate[SeqMap]
- object Set extends Delegate[Set]
This object provides a set of operations to create
mutable.Set
values.This object provides a set of operations to create
mutable.Set
values.- Annotations
- @SerialVersionUID()
- object SortedMap extends Delegate[SortedMap]
- Annotations
- @SerialVersionUID()
- object SortedSet extends Delegate[SortedSet]
This object provides a set of operations to create
mutable.Sortedset
values.This object provides a set of operations to create
mutable.Sortedset
values.- Annotations
- @SerialVersionUID()
- object Stack extends StrictOptimizedSeqFactory[Stack]
This object provides a set of operations to create
Stack
values.This object provides a set of operations to create
Stack
values.- Annotations
- @SerialVersionUID()
- object StringBuilder extends java.io.Serializable
- object TreeMap extends SortedMapFactory[TreeMap]
This object provides a set of operations to create mutable.TreeMap values.
This object provides a set of operations to create mutable.TreeMap values.
- Annotations
- @SerialVersionUID()
- object TreeSet extends SortedIterableFactory[TreeSet]
This object provides a set of operations to create
mutable.TreeSet
values.This object provides a set of operations to create
mutable.TreeSet
values.- Annotations
- @SerialVersionUID()
- object UnrolledBuffer extends StrictOptimizedClassTagSeqFactory[UnrolledBuffer]
- Annotations
- @SerialVersionUID()
- object WeakHashMap extends MapFactory[WeakHashMap]
This object provides a set of operations to create
WeakHashMap
values.This object provides a set of operations to create
WeakHashMap
values.- Annotations
- @SerialVersionUID()
Deprecated Value Members
- val ArrayStack: Stack.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use Stack instead of ArrayStack; it now uses an array-based implementation
- val Traversable: Iterable.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use Iterable instead of Traversable
- val WrappedArray: ArraySeq.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use ArraySeq instead of WrappedArray; it can represent both, boxed and unboxed arrays
- object ListMap extends MapFactory[ListMap]
This object provides a set of operations to create
mutable.ListMap
values.This object provides a set of operations to create
mutable.ListMap
values.- Annotations
- @SerialVersionUID() @deprecated
- Deprecated
(Since version 2.13.0) Use an immutable.ListMap assigned to a var instead of mutable.ListMap
- object OpenHashMap extends MapFactory[OpenHashMap]
- Annotations
- @deprecated @SerialVersionUID()
- Deprecated
(Since version 2.13.0) Use HashMap or one of the specialized versions (LongMap, AnyRefMap) instead of OpenHashMap
This is the documentation for the Scala standard library.
Package structure
The scala package contains core types like
Int
,Float
,Array
orOption
which are accessible in all Scala compilation units without explicit qualification or imports.Notable packages include:
scala.collection
and its sub-packages contain Scala's collections frameworkscala.collection.immutable
- Immutable, sequential data-structures such asVector
,List
,Range
,HashMap
orHashSet
scala.collection.mutable
- Mutable, sequential data-structures such asArrayBuffer
,StringBuilder
,HashMap
orHashSet
scala.collection.concurrent
- Mutable, concurrent data-structures such asTrieMap
scala.concurrent
- Primitives for concurrent programming such asFutures
andPromises
scala.io
- Input and output operationsscala.math
- Basic math functions and additional numeric types likeBigInt
andBigDecimal
scala.sys
- Interaction with other processes and the operating systemscala.util.matching
- Regular expressionsOther packages exist. See the complete list on the right.
Additional parts of the standard library are shipped as separate libraries. These include:
scala.reflect
- Scala's reflection API (scala-reflect.jar)scala.xml
- XML parsing, manipulation, and serialization (scala-xml.jar)scala.collection.parallel
- Parallel collections (scala-parallel-collections.jar)scala.util.parsing
- Parser combinators (scala-parser-combinators.jar)scala.swing
- A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)Automatic imports
Identifiers in the scala package and the
scala.Predef
object are always in scope by default.Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example,
List
is an alias forscala.collection.immutable.List
.Other aliases refer to classes provided by the underlying platform. For example, on the JVM,
String
is an alias forjava.lang.String
.