package collection
- Alphabetic
- By Inheritance
- collection
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Package Members
Type Members
- abstract class AbstractIndexedSeqView[+A] extends AbstractSeqView[A] with IndexedSeqView[A]
Explicit instantiation of the
IndexedSeqView
trait to reduce class file size in subclasses.Explicit instantiation of the
IndexedSeqView
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- abstract class AbstractIterable[+A] extends Iterable[A]
Explicit instantiation of the
Iterable
trait to reduce class file size in subclasses. - abstract class AbstractIterator[+A] extends Iterator[A]
Explicit instantiation of the
Iterator
trait to reduce class file size in subclasses. - abstract class AbstractMap[K, +V] extends AbstractIterable[(K, V)] with Map[K, V]
Explicit instantiation of the
Map
trait to reduce class file size in subclasses.Explicit instantiation of the
Map
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- abstract class AbstractMapView[K, +V] extends AbstractView[(K, V)] with MapView[K, V]
Explicit instantiation of the
MapView
trait to reduce class file size in subclasses.Explicit instantiation of the
MapView
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- abstract class AbstractSeq[+A] extends AbstractIterable[A] with Seq[A]
Explicit instantiation of the
Seq
trait to reduce class file size in subclasses.Explicit instantiation of the
Seq
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- abstract class AbstractSeqView[+A] extends AbstractView[A] with SeqView[A]
Explicit instantiation of the
SeqView
trait to reduce class file size in subclasses.Explicit instantiation of the
SeqView
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- abstract class AbstractSet[A] extends AbstractIterable[A] with Set[A]
Explicit instantiation of the
Set
trait to reduce class file size in subclasses.Explicit instantiation of the
Set
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- abstract class AbstractView[+A] extends AbstractIterable[A] with View[A]
Explicit instantiation of the
View
trait to reduce class file size in subclasses.Explicit instantiation of the
View
trait to reduce class file size in subclasses.- Annotations
- @SerialVersionUID()
- trait AnyStepper[+A] extends Stepper[A]
A Stepper for arbitrary element types.
A Stepper for arbitrary element types. See Stepper.
- final class ArrayOps[A] extends AnyVal
This class serves as a wrapper for
Array
s with many of the operations found in indexed sequences.This class serves as a wrapper for
Array
s with many of the operations found in indexed sequences. Where needed, instances of arrays are implicitly converted into this class. There is generally no reason to create an instance explicitly or use anArrayOps
type. It is better to work with plainArray
types instead and rely on the implicit conversion toArrayOps
when calling a method (which does not actually allocate an instance ofArrayOps
because it is a value class).Neither
Array
norArrayOps
are proper collection types (i.e. they do not extendIterable
or evenIterableOnce
).mutable.ArraySeq
andimmutable.ArraySeq
serve this purpose.The difference between this class and
ArraySeq
s is that calling transformer methods such asfilter
andmap
will yield an array, whereas anArraySeq
will remain anArraySeq
.- A
type of the elements contained in this array.
- Since
2.8
- trait BitSet extends SortedSet[Int] with BitSetOps[BitSet]
Base type of bitsets.
Base type of bitsets.
This trait provides most of the operations of a
BitSet
independently of its representation. It is inherited by all concrete implementations of bitsets. - trait BitSetOps[+C <: BitSet with BitSetOps[C]] extends SortedSetOps[Int, SortedSet, C]
Base implementation type of bitsets
- trait BufferedIterator[+A] extends Iterator[A]
Buffered iterators are iterators which provide a method
head
that inspects the next element without discarding it.Buffered iterators are iterators which provide a method
head
that inspects the next element without discarding it.- Since
2.8
- trait BuildFrom[-From, -A, +C] extends Any
Builds a collection of type
C
from elements of typeA
when a source collection of typeFrom
is available.Builds a collection of type
C
from elements of typeA
when a source collection of typeFrom
is available. Implicit instances ofBuildFrom
are available for all collection types.- From
Type of source collection
- A
Type of elements (e.g.
Int
,Boolean
, etc.)- C
Type of collection (e.g.
List[Int]
,TreeMap[Int, String]
, etc.)
- Annotations
- @implicitNotFound("Cannot construct a collection of type ${C} with elements of type ${A} based on a collection of type ${From}.")
- trait BuildFromLowPriority1 extends BuildFromLowPriority2
- trait BuildFromLowPriority2 extends AnyRef
- trait ClassTagIterableFactory[+CC[_]] extends EvidenceIterableFactory[CC, ClassTag]
Base trait for companion objects of collections that require an implicit
ClassTag
.Base trait for companion objects of collections that require an implicit
ClassTag
.- CC
Collection type constructor (e.g.
ArraySeq
)
- trait ClassTagSeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]]] extends ClassTagIterableFactory[CC]
- CC
Collection type constructor (e.g.
ArraySeq
)
- trait DoubleStepper extends Stepper[Double]
A Stepper for Doubles.
A Stepper for Doubles. See Stepper.
- trait EvidenceIterableFactory[+CC[_], Ev[_]] extends Serializable
Base trait for companion objects of collections that require an implicit evidence.
Base trait for companion objects of collections that require an implicit evidence.
- CC
Collection type constructor (e.g.
ArraySeq
)- Ev
Unary type constructor for the implicit evidence required for an element type (typically
Ordering
orClassTag
)
- trait EvidenceIterableFactoryDefaults[+A, +CC[x] <: IterableOps[x, CC, CC[x]], Ev[_]] extends IterableOps[A, CC, CC[A]]
This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters.This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters. It is used for collections that have an additional constraint, expressed by theevidenceIterableFactory
method.The default implementations in this trait can be used in the common case when
CC[A]
is the same asC
. - trait Factory[-A, +C] extends Any
A factory that builds a collection of type
C
with elements of typeA
.A factory that builds a collection of type
C
with elements of typeA
.This is a general form of any factory (IterableFactory, SortedIterableFactory, MapFactory and SortedMapFactory) whose element type is fixed.
- A
Type of elements (e.g.
Int
,Boolean
, etc.)- C
Type of collection (e.g.
List[Int]
,TreeMap[Int, String]
, etc.)
- trait IndexedSeq[+A] extends Seq[A] with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]] with IterableFactoryDefaults[A, IndexedSeq]
Base trait for indexed sequences that have efficient
apply
andlength
- trait IndexedSeqOps[+A, +CC[_], +C] extends SeqOps[A, CC, C]
Base trait for indexed Seq operations
- trait IndexedSeqView[+A] extends IndexedSeqOps[A, View, View[A]] with SeqView[A]
View defined in terms of indexing a range
- trait IntStepper extends Stepper[Int]
A Stepper for Ints.
A Stepper for Ints. See Stepper.
- trait Iterable[+A] extends IterableOnce[A] with IterableOps[A, Iterable, Iterable[A]] with IterableFactoryDefaults[A, Iterable]
Base trait for generic collections.
Base trait for generic collections.
- A
the element type of the collection
- trait IterableFactory[+CC[_]] extends Serializable
Base trait for companion objects of unconstrained collection types that may require multiple traversals of a source collection to build a target collection
CC
.Base trait for companion objects of unconstrained collection types that may require multiple traversals of a source collection to build a target collection
CC
.- CC
Collection type constructor (e.g.
List
)
- trait IterableFactoryDefaults[+A, +CC[x] <: IterableOps[x, CC, CC[x]]] extends IterableOps[A, CC, CC[A]]
This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters.This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters.The default implementations in this trait can be used in the common case when
CC[A]
is the same asC
. - trait IterableOnce[+A] extends Any
A template trait for collections which can be traversed either once only or one or more times.
A template trait for collections which can be traversed either once only or one or more times.
Note:
IterableOnce
does not extend IterableOnceOps. This is different than the general design of the collections library, which uses the following pattern:trait Seq extends Iterable with SeqOps trait SeqOps extends IterableOps trait IndexedSeq extends Seq with IndexedSeqOps trait IndexedSeqOps extends SeqOps
The goal is to provide a minimal interface without any sequential operations. This allows third-party extension like Scala parallel collections to integrate at the level of IterableOnce without inheriting unwanted implementations.
- final class IterableOnceExtensionMethods[A] extends AnyVal
- trait IterableOnceOps[+A, +CC[_], +C] extends Any
This implementation trait can be mixed into an
IterableOnce
to get the basic methods that are shared betweenIterator
andIterable
.This implementation trait can be mixed into an
IterableOnce
to get the basic methods that are shared betweenIterator
andIterable
. TheIterableOnce
must support multiple calls toiterator
but may or may not return the sameIterator
every time. - trait IterableOps[+A, +CC[_], +C] extends IterableOnce[A] with IterableOnceOps[A, CC, C]
Base trait for Iterable operations
Base trait for Iterable operations
VarianceNote
We require that for all child classes of Iterable the variance of the child class and the variance of the
C
parameter passed toIterableOps
are the same. We cannot express this since we lack variance polymorphism. That's why we have to resort at some places to writeC[A @uncheckedVariance]
.- CC
type constructor of the collection (e.g.
List
,Set
). Operations returning a collection with a different type of elementB
(e.g.map
) return aCC[B]
.- C
type of the collection (e.g.
List[Int]
,String
,BitSet
). Operations returning a collection with the same type of element (e.g.drop
,filter
) return aC
.
- trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Iterator[A]]
Iterators are data structures that allow to iterate over a sequence of elements.
Iterators are data structures that allow to iterate over a sequence of elements. They have a
hasNext
method for checking if there is a next element available, and anext
method which returns the next element and advances the iterator.An iterator is mutable: most operations on it change its state. While it is often used to iterate through the elements of a collection, it can also be used without being backed by any collection (see constructors on the companion object).
It is of particular importance to note that, unless stated otherwise, one should never use an iterator after calling a method on it. The two most important exceptions are also the sole abstract methods:
next
andhasNext
.Both these methods can be called any number of times without having to discard the iterator. Note that even
hasNext
may cause mutation -- such as when iterating from an input stream, where it will block until the stream is closed or some input becomes available.Consider this example for safe and unsafe use:
def f[A](it: Iterator[A]) = { if (it.hasNext) { // Safe to reuse "it" after "hasNext" it.next // Safe to reuse "it" after "next" val remainder = it.drop(2) // it is *not* safe to use "it" again after this line! remainder.take(2) // it is *not* safe to use "remainder" after this line! } else it }
- final class LazyZip2[+El1, +El2, C1] extends AnyRef
Decorator representing lazily zipped pairs.
- final class LazyZip3[+El1, +El2, +El3, C1] extends AnyRef
Decorator representing lazily zipped triples.
- final class LazyZip4[+El1, +El2, +El3, +El4, C1] extends AnyRef
Decorator representing lazily zipped 4-tuples.
- trait LinearSeq[+A] extends Seq[A] with LinearSeqOps[A, LinearSeq, LinearSeq[A]] with IterableFactoryDefaults[A, LinearSeq]
Base trait for linearly accessed sequences that have efficient
head
andtail
operations.Base trait for linearly accessed sequences that have efficient
head
andtail
operations. Known subclasses: List, LazyList - trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeqOps[A, CC, C]] extends SeqOps[A, CC, C]
Base trait for linear Seq operations
- trait LongStepper extends Stepper[Long]
A Stepper for Longs.
A Stepper for Longs. See Stepper.
- trait Map[K, +V] extends Iterable[(K, V)] with MapOps[K, V, Map, Map[K, V]] with MapFactoryDefaults[K, V, Map, Iterable] with Equals
Base Map type
- trait MapFactory[+CC[_, _]] extends Serializable
- trait MapFactoryDefaults[K, +V, +CC[x, y] <: IterableOps[(x, y), Iterable, Iterable[(x, y)]], +WithFilterCC[x] <: IterableOps[x, WithFilterCC, WithFilterCC[x]] with Iterable[x]] extends MapOps[K, V, CC, CC[K, V]] with IterableOps[(K, V), WithFilterCC, CC[K, V]]
This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters.This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters. It is used for maps.Note that in maps, the
CC
type of the map is not the same as theCC
type for the underlying iterable (which is fixed toMap
in MapOps). This trait has therefore two type parametersCC
andWithFilterCC
. ThewithFilter
method inherited fromIterableOps
is overridden with a compatible default implementation.The default implementations in this trait can be used in the common case when
CC[A]
is the same asC
. - trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, collection.AnyConstr, _], +C] extends IterableOps[(K, V), Iterable, C] with PartialFunction[K, V]
Base Map implementation type
Base Map implementation type
- K
Type of keys
- V
Type of values
- CC
type constructor of the map (e.g.
HashMap
). Operations returning a collection with a different type of entries(L, W)
(e.g.map
) return aCC[L, W]
.- C
type of the map (e.g.
HashMap[Int, String]
). Operations returning a collection with the same type of element (e.g.drop
,filter
) return aC
.
- trait MapView[K, +V] extends MapOps[K, V, [X, Y]View[(X, Y)], View[(K, V)]] with View[(K, V)]
- trait MapViewFactory extends MapFactory[[X, Y]View[(X, Y)]]
- trait Seq[+A] extends Iterable[A] with PartialFunction[Int, A] with SeqOps[A, Seq, Seq[A]] with IterableFactoryDefaults[A, Seq] with Equals
Base trait for sequence collections
Base trait for sequence collections
- A
the element type of the collection
- trait SeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]]] extends IterableFactory[CC]
- CC
Collection type constructor (e.g.
List
)
- trait SeqMap[K, +V] extends Map[K, V] with MapOps[K, V, SeqMap, SeqMap[K, V]] with MapFactoryDefaults[K, V, SeqMap, Iterable]
A generic trait for ordered maps.
A generic trait for ordered 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.
- Version
2.13
- Since
2.13
- trait SeqOps[+A, +CC[_], +C] extends IterableOps[A, CC, C]
Base trait for Seq operations
Base trait for Seq operations
- A
the element type of the collection
- CC
type constructor of the collection (e.g.
List
,Set
). Operations returning a collection with a different type of elementB
(e.g.map
) return aCC[B]
.- C
type of the collection (e.g.
List[Int]
,String
,BitSet
). Operations returning a collection with the same type of element (e.g.drop
,filter
) return aC
.
- trait SeqView[+A] extends SeqOps[A, View, View[A]] with View[A]
- trait Set[A] extends Iterable[A] with SetOps[A, Set, Set[A]] with Equals with IterableFactoryDefaults[A, Set]
Base trait for set collections.
- trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]] extends IterableOps[A, CC, C] with (A) => Boolean
Base trait for set operations
- trait SortedIterableFactory[+CC[_]] extends EvidenceIterableFactory[CC, Ordering]
Base trait for companion objects of collections that require an implicit
Ordering
.Base trait for companion objects of collections that require an implicit
Ordering
.- CC
Collection type constructor (e.g.
SortedSet
)
- trait SortedMap[K, +V] extends Map[K, V] with SortedMapOps[K, V, SortedMap, SortedMap[K, V]] with SortedMapFactoryDefaults[K, V, SortedMap, Iterable, Map]
A Map whose keys are sorted according to a scala.math.Ordering
- trait SortedMapFactory[+CC[_, _]] extends Serializable
- trait SortedMapFactoryDefaults[K, +V, +CC[x, y] <: Map[x, y] with SortedMapOps[x, y, CC, CC[x, y]] with UnsortedCC[x, y], +WithFilterCC[x] <: IterableOps[x, WithFilterCC, WithFilterCC[x]] with Iterable[x], +UnsortedCC[x, y] <: Map[x, y]] extends SortedMapOps[K, V, CC, CC[K, V]] with MapOps[K, V, UnsortedCC, CC[K, V]]
This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters.This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters. It is used for sorted maps.Note that in sorted maps, the
CC
type of the map is not the same as theCC
type for the underlying map (which is fixed toMap
in SortedMapOps). This trait has therefore three type parametersCC
,WithFilterCC
andUnsortedCC
. ThewithFilter
method inherited fromIterableOps
is overridden with a compatible default implementation.The default implementations in this trait can be used in the common case when
CC[A]
is the same asC
. - trait SortedMapOps[K, +V, +CC[X, Y] <: Map[X, Y] with SortedMapOps[X, Y, CC, _], +C <: SortedMapOps[K, V, CC, C]] extends MapOps[K, V, Map, C] with SortedOps[K, C]
- trait SortedOps[A, +C] extends AnyRef
Base trait for sorted collections
- trait SortedSet[A] extends Set[A] with SortedSetOps[A, SortedSet, SortedSet[A]] with SortedSetFactoryDefaults[A, SortedSet, Set]
Base type of sorted sets
- trait SortedSetFactoryDefaults[+A, +CC[X] <: SortedSet[X] with SortedSetOps[X, CC, CC[X]], +WithFilterCC[x] <: IterableOps[x, WithFilterCC, WithFilterCC[x]] with Set[x]] extends SortedSetOps[A, CC, CC[A]]
This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters.This trait provides default implementations for the factory methods
fromSpecific
andnewSpecificBuilder
that need to be refined when implementing a collection type that refines theCC
andC
type parameters. It is used for sorted sets.Note that in sorted sets, the
CC
type of the set is not the same as theCC
type for the underlying iterable (which is fixed toSet
in SortedSetOps). This trait has therefore two type parametersCC
andWithFilterCC
. ThewithFilter
method inherited fromIterableOps
is overridden with a compatible default implementation.The default implementations in this trait can be used in the common case when
CC[A]
is the same asC
. - trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]] extends SetOps[A, Set, C] with SortedOps[A, C]
- trait SpecificIterableFactory[-A, +C] extends Factory[A, C]
- A
Type of elements (e.g.
Int
,Boolean
, etc.)- C
Type of collection (e.g.
List[Int]
,TreeMap[Int, String]
, etc.)
- trait Stepper[+A] extends AnyRef
Steppers exist to enable creating Java streams over Scala collections, see scala.jdk.StreamConverters.
Steppers exist to enable creating Java streams over Scala collections, see scala.jdk.StreamConverters. Besides that use case, they allow iterating over collections holding unboxed primitives (e.g.,
Array[Int]
) without boxing the elements.Steppers have an iterator-like interface with methods
hasStep
andnextStep()
. The difference to iterators - and the reasonStepper
is not a subtype ofIterator
- is that there are hand-specialized variants ofStepper
forInt
,Long
andDouble
(IntStepper, etc.). These enable iterating over collections holding unboxed primitives (e.g., Arrays, scala.jdk.Accumulators) without boxing the elements.The selection of primitive types (
Int
,Long
andDouble
) matches the hand-specialized variants of Java Streams (java.util.stream.Stream, java.util.stream.IntStream, etc.) and the corresponding Java Spliterators (Spliterator, Spliterator.OfInt, etc.).Steppers can be converted to Scala Iterators, Java Iterators and Java Spliterators. Primitive Steppers are converted to the corresponding primitive Java Iterators and Spliterators.
- A
the element type of the Stepper
- sealed trait StepperShape[-T, S <: Stepper[_]] extends AnyRef
An implicit StepperShape instance is used in the IterableOnce.stepper to return a possibly specialized Stepper
S
according to the element typeT
. - trait StepperShapeLowPriority1 extends StepperShapeLowPriority2
- trait StepperShapeLowPriority2 extends AnyRef
- trait StrictOptimizedClassTagSeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]]] extends ClassTagSeqFactory[CC]
- trait StrictOptimizedIterableOps[+A, +CC[_], +C] extends IterableOps[A, CC, C]
Trait that overrides iterable operations to take advantage of strict builders.
Trait that overrides iterable operations to take advantage of strict builders.
- A
Elements type
- CC
Collection type constructor
- C
Collection type
- trait StrictOptimizedLinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with StrictOptimizedLinearSeqOps[A, CC, C]] extends LinearSeqOps[A, CC, C] with StrictOptimizedSeqOps[A, CC, C]
- trait StrictOptimizedMapOps[K, +V, +CC[_, _] <: IterableOps[_, collection.AnyConstr, _], +C] extends MapOps[K, V, CC, C] with StrictOptimizedIterableOps[(K, V), Iterable, C]
Trait that overrides map operations to take advantage of strict builders.
Trait that overrides map operations to take advantage of strict builders.
- K
Type of keys
- V
Type of values
- CC
Collection type constructor
- C
Collection type
- trait StrictOptimizedSeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]]] extends SeqFactory[CC]
- trait StrictOptimizedSeqOps[+A, +CC[_], +C] extends SeqOps[A, CC, C] with StrictOptimizedIterableOps[A, CC, C]
Trait that overrides operations on sequences in order to take advantage of strict builders.
- trait StrictOptimizedSetOps[A, +CC[_], +C <: SetOps[A, CC, C]] extends SetOps[A, CC, C] with StrictOptimizedIterableOps[A, CC, C]
Trait that overrides set operations to take advantage of strict builders.
Trait that overrides set operations to take advantage of strict builders.
- A
Elements type
- CC
Collection type constructor
- C
Collection type
- trait StrictOptimizedSortedMapOps[K, +V, +CC[X, Y] <: Map[X, Y] with SortedMapOps[X, Y, CC, _], +C <: SortedMapOps[K, V, CC, C]] extends SortedMapOps[K, V, CC, C] with StrictOptimizedMapOps[K, V, Map, C]
Trait that overrides sorted map operations to take advantage of strict builders.
Trait that overrides sorted map operations to take advantage of strict builders.
- K
Type of keys
- V
Type of values
- CC
Collection type constructor
- C
Collection type
- trait StrictOptimizedSortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]] extends SortedSetOps[A, CC, C] with StrictOptimizedSetOps[A, Set, C]
Trait that overrides sorted set operations to take advantage of strict builders.
Trait that overrides sorted set operations to take advantage of strict builders.
- A
Elements type
- CC
Collection type constructor
- C
Collection type
- final class StringOps extends AnyVal
- final case class StringView(s: String) extends AbstractIndexedSeqView[Char] with Product with Serializable
- trait View[+A] extends Iterable[A] with IterableOps[A, View, View[A]] with IterableFactoryDefaults[A, View] with Serializable
Views are collections whose transformation operations are non strict: the resulting elements are evaluated only when the view is effectively traversed (e.g.
Views are collections whose transformation operations are non strict: the resulting elements are evaluated only when the view is effectively traversed (e.g. using
foreach
orfoldLeft
), or when the view is converted to a strict collection type (using theto
operation). - abstract class WithFilter[+A, +CC[_]] extends Serializable
A template trait that contains just the
map
,flatMap
,foreach
andwithFilter
methods of traitIterable
.A template trait that contains just the
map
,flatMap
,foreach
andwithFilter
methods of traitIterable
.- A
Element type (e.g.
Int
)- CC
Collection type constructor (e.g.
List
)
- Annotations
- @SerialVersionUID()
Deprecated Type Members
- type ArrayLike[A] = SeqOps[A, Seq, Seq[A]]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use SeqOps (for the methods) or IndexedSeqOps (for fast indexed access) instead of ArrayLike
- trait DefaultMap[K, +V] extends Map[K, V]
A default map which builds a default
immutable.Map
implementation for all transformations.A default map which builds a default
immutable.Map
implementation for all transformations.- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) DefaultMap is no longer necessary; extend Map directly
- Since
2.8
- type GenIterable[+X] = Iterable[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- type GenMap[K, +V] = Map[K, V]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- type GenSeq[+X] = Seq[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- type GenSet[X] = Set[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- type GenTraversable[+X] = Iterable[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- type GenTraversableOnce[+X] = IterableOnce[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- type SeqLike[A, T] = SeqOps[A, Seq, T]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use SeqOps instead of SeqLike
- type Traversable[+X] = Iterable[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use Iterable instead of Traversable
- type TraversableOnce[+X] = IterableOnce[X]
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use IterableOnce instead of TraversableOnce
Value Members
- object +:
An extractor used to head/tail deconstruct sequences.
- object :+
An extractor used to init/last deconstruct sequences.
- object AnyStepper
- object ArrayOps
- object BitSet extends SpecificIterableFactory[Int, BitSet]
- Annotations
- @SerialVersionUID()
- object BitSetOps
- object BuildFrom extends BuildFromLowPriority1
- object ClassTagIterableFactory extends java.io.Serializable
- object ClassTagSeqFactory extends java.io.Serializable
- object DoubleStepper
- object EvidenceIterableFactory extends java.io.Serializable
- object Factory
- object Hashing
- Attributes
- protected
- object IndexedSeq extends Delegate[IndexedSeq]
- Annotations
- @SerialVersionUID()
- object IndexedSeqView extends java.io.Serializable
- object IntStepper
- object Iterable extends Delegate[Iterable]
- Annotations
- @SerialVersionUID()
- object IterableFactory extends java.io.Serializable
- object IterableOnce
- object IterableOps
- object Iterator extends IterableFactory[Iterator]
- Annotations
- @SerialVersionUID()
- object LazyZip2
- object LazyZip3
- object LazyZip4
- object LinearSeq extends Delegate[LinearSeq]
- Annotations
- @SerialVersionUID()
- object LongStepper
- object Map extends Delegate[Map]
This object provides a set of operations to create
Map
values.This object provides a set of operations to create
Map
values.- Annotations
- @SerialVersionUID()
- object MapFactory extends java.io.Serializable
- object MapOps
- object MapView extends MapViewFactory
- object Searching
- object Seq extends Delegate[Seq]
This object provides a set of operations to create
Seq
values.This object provides a set of operations to create
Seq
values.- Annotations
- @SerialVersionUID()
- object SeqFactory extends java.io.Serializable
- object SeqMap extends Delegate[collection.immutable.SeqMap]
- object SeqOps
- object SeqView extends java.io.Serializable
- object Set extends Delegate[Set]
This object provides a set of operations to create
Set
values.This object provides a set of operations to create
Set
values.- Annotations
- @SerialVersionUID()
- object SortedIterableFactory extends java.io.Serializable
- object SortedMap extends Delegate[SortedMap]
- Annotations
- @SerialVersionUID()
- object SortedMapFactory extends java.io.Serializable
- object SortedMapOps
- object SortedSet extends Delegate[SortedSet]
- Annotations
- @SerialVersionUID()
- object SortedSetOps
- object Stepper
- object StepperShape extends StepperShapeLowPriority1
- object StringOps
- object View extends IterableFactory[View]
This object reifies operations on views as case classes
This object reifies operations on views as case classes
- Annotations
- @SerialVersionUID()
Deprecated Value Members
- val GenIterable: Iterable.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- val GenMap: Map.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- val GenSeq: Seq.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- val GenSet: Set.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- val GenTraversable: Iterable.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- val GenTraversableOnce: IterableOnce.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Gen* collection types have been removed
- val Traversable: Iterable.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use Iterable instead of Traversable
- val TraversableOnce: IterableOnce.type
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use IterableOnce instead of TraversableOnce
- object JavaConverters extends AsJavaConverters with AsScalaConverters
A variety of decorators that enable converting between Scala and Java collections using extension methods,
asScala
andasJava
.A variety of decorators that enable converting between Scala and Java collections using extension methods,
asScala
andasJava
.The extension methods return adapters for the corresponding API.
The following conversions are supported via
asScala
andasJava
:scala.collection.Iterable <=> java.lang.Iterable scala.collection.Iterator <=> java.util.Iterator scala.collection.mutable.Buffer <=> java.util.List scala.collection.mutable.Set <=> java.util.Set scala.collection.mutable.Map <=> java.util.Map scala.collection.concurrent.Map <=> java.util.concurrent.ConcurrentMap
The following conversions are supported via
asScala
and through specially-named extension methods to convert to Java collections, as shown:scala.collection.Iterable <=> java.util.Collection (via asJavaCollection) scala.collection.Iterator <=> java.util.Enumeration (via asJavaEnumeration) scala.collection.mutable.Map <=> java.util.Dictionary (via asJavaDictionary)
In addition, the following one-way conversions are provided via
asJava
:scala.collection.Seq => java.util.List scala.collection.mutable.Seq => java.util.List scala.collection.Set => java.util.Set scala.collection.Map => java.util.Map
The following one way conversion is provided via
asScala
:java.util.Properties => scala.collection.mutable.Map
In all cases, converting from a source type to a target type and back again will return the original source object. For example:
import scala.collection.JavaConverters._ val source = new scala.collection.mutable.ListBuffer[Int] val target: java.util.List[Int] = source.asJava val other: scala.collection.mutable.Buffer[Int] = target.asScala assert(source eq other)
Alternatively, the conversion methods have descriptive names and can be invoked explicitly.
scala> val vs = java.util.Arrays.asList("hi", "bye") vs: java.util.List[String] = [hi, bye] scala> val ss = asScalaIterator(vs.iterator) ss: Iterator[String] = <iterator> scala> .toList res0: List[String] = List(hi, bye) scala> val ss = asScalaBuffer(vs) ss: scala.collection.mutable.Buffer[String] = Buffer(hi, bye)
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
scala.jdk.CollectionConverters
instead- Since
2.8.1
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
.