An extractor used to head/tail deconstruct sequences.
An extractor used to head/tail deconstruct sequences.
An extractor used to init/last deconstruct sequences.
An extractor used to init/last deconstruct sequences.
Explicit instantiation of theIndexedSeqView trait to reduce class file size in subclasses.
Explicit instantiation of theIndexedSeqView trait to reduce class file size in subclasses.
Explicit instantiation of theIterable trait to reduce class file size in subclasses.
Explicit instantiation of theIterable trait to reduce class file size in subclasses.
Explicit instantiation of theIterator trait to reduce class file size in subclasses.
Explicit instantiation of theIterator trait to reduce class file size in subclasses.
Explicit instantiation of theMap trait to reduce class file size in subclasses.
Explicit instantiation of theMap trait to reduce class file size in subclasses.
Explicit instantiation of theMapView trait to reduce class file size in subclasses.
Explicit instantiation of theMapView trait to reduce class file size in subclasses.
Explicit instantiation of theSeq trait to reduce class file size in subclasses.
Explicit instantiation of theSeq trait to reduce class file size in subclasses.
Explicit instantiation of theSeqView trait to reduce class file size in subclasses.
Explicit instantiation of theSeqView trait to reduce class file size in subclasses.
Explicit instantiation of theSet trait to reduce class file size in subclasses.
Explicit instantiation of theSet trait to reduce class file size in subclasses.
Explicit instantiation of theView trait to reduce class file size in subclasses.
Explicit instantiation of theView trait to reduce class file size in subclasses.
This class serves as a wrapper forArrays with many of the operations found in indexed sequences.
This class serves as a wrapper forArrays 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).
NeitherArray 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 andArraySeqs is that calling transformer methods such asfilter andmap will yield an array, whereas anArraySeq will remain anArraySeq.
type of the elements contained in this array.
Base type of bitsets.
Base type of bitsets.
This trait provides most of the operations of aBitSet independently of its representation. It is inherited by all concrete implementations of bitsets.
Base implementation type of bitsets
Base implementation type of bitsets
Buffered iterators are iterators which provide a methodhead that inspects the next element without discarding it.
Buffered iterators are iterators which provide a methodhead that inspects the next element without discarding it.
Builds a collection of typeC from elements of typeA when a source collection of typeFrom is available.
Builds a collection of typeC from elements of typeA when a source collection of typeFrom is available. Implicit instances ofBuildFrom are available for all collection types.
Type of elements (e.g.Int,Boolean, etc.)
Type of collection (e.g.List[Int],TreeMap[Int, String], etc.)
Type of source collection
Base trait for companion objects of collections that require an implicitClassTag.
Base trait for companion objects of collections that require an implicitClassTag.
Collection type constructor (e.g.ArraySeq)
Collection type constructor (e.g.ArraySeq)
Base trait for companion objects of collections that require an implicit evidence.
Base trait for companion objects of collections that require an implicit evidence.
Collection type constructor (e.g.ArraySeq)
Unary type constructor for the implicit evidence required for an element type (typicallyOrdering orClassTag)
This trait provides default implementations for the factory methodsfromSpecific 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 methodsfromSpecific 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 whenCC[A] is the same asC.
A factory that builds a collection of typeC with elements of typeA.
A factory that builds a collection of typeC with elements of typeA.
This is a general form of any factory (IterableFactory,SortedIterableFactory,MapFactory andSortedMapFactory) whose element type is fixed.
Type of elements (e.g.Int,Boolean, etc.)
Type of collection (e.g.List[Int],TreeMap[Int, String], etc.)
Base trait for indexed sequences that have efficientapply andlength
Base trait for indexed sequences that have efficientapply andlength
Base trait for indexed Seq operations
Base trait for indexed Seq operations
View defined in terms of indexing a range
View defined in terms of indexing a range
Base trait for generic collections.
Base trait for generic collections.
the element type of the collection
Base trait for companion objects of unconstrained collection types that may require multiple traversals of a source collection to build a target collectionCC.
Base trait for companion objects of unconstrained collection types that may require multiple traversals of a source collection to build a target collectionCC.
Collection type constructor (e.g.List)
This trait provides default implementations for the factory methodsfromSpecific 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 methodsfromSpecific 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 whenCC[A] is the same asC.
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 extendIterableOnceOps. This is different than the general design of the collections library, which uses the following pattern:
trait Seq extends Iterable with SeqOpstrait SeqOps extends IterableOpstrait IndexedSeq extends Seq with IndexedSeqOpstrait IndexedSeqOps extends SeqOpsThe 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.
This implementation trait can be mixed into anIterableOnce to get the basic methods that are shared betweenIterator andIterable.
This implementation trait can be mixed into anIterableOnce 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.
Base trait for Iterable operations
Base trait for Iterable operations
We require that for all child classes of Iterable the variance of the child class and the variance of theC 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].
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.
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].
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 ahasNext 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 evenhasNext 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}Decorator representing lazily zipped pairs.
Decorator representing lazily zipped pairs.
Decorator representing lazily zipped triples.
Decorator representing lazily zipped triples.
Decorator representing lazily zipped 4-tuples.
Decorator representing lazily zipped 4-tuples.
Base trait for linearly accessed sequences that have efficienthead andtail operations.
Base trait for linearly accessed sequences that have efficienthead andtail operations. Known subclasses: List, LazyList
Base trait for linear Seq operations
Base trait for linear Seq operations
Base Map type
Base Map type
This object provides a set of operations to createIterable values.
This trait provides default implementations for the factory methodsfromSpecific 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 methodsfromSpecific 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, theCC type of the map is not the same as theCC type for the underlying iterable (which is fixed toMap inMapOps). 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 whenCC[A] is the same asC.
Base Map implementation type
Base Map implementation type
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.
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].
Type of keys
Type of values
Base trait for sequence collections
Base trait for sequence collections
the element type of the collection
This object provides a set of operations to createIterable values.
This object provides a set of operations to createIterable values.
Collection type constructor (e.g.List)
A generic trait for ordered maps.
A generic trait for ordered maps. Concrete classes have to provide functionality for the abstract methods inSeqMap.
Note that when checking for equalitySeqMap does not take into account ordering.
the type of the keys contained in this linked map.
the type of the values associated with the keys in this linked map.
Base trait for Seq operations
Base trait for Seq operations
the element type of the collection
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.
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].
Base trait for set collections.
Base trait for set collections.
This object provides a set of operations to createIterable values.
Base trait for set operations
Base trait for set operations
Base trait for companion objects of collections that require an implicitOrdering.
Base trait for companion objects of collections that require an implicitOrdering.
Collection type constructor (e.g.SortedSet)
A Map whose keys are sorted according to ascala.math.Ordering
A Map whose keys are sorted according to ascala.math.Ordering
This trait provides default implementations for the factory methodsfromSpecific 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 methodsfromSpecific 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, theCC type of the map is not the same as theCC type for the underlying map (which is fixed toMap inSortedMapOps). 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 whenCC[A] is the same asC.
Base trait for sorted collections
Base trait for sorted collections
Base type of sorted sets
Base type of sorted sets
This trait provides default implementations for the factory methodsfromSpecific 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 methodsfromSpecific 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, theCC type of the set is not the same as theCC type for the underlying iterable (which is fixed toSet inSortedSetOps). 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 whenCC[A] is the same asC.
Type of elements (e.g.Int,Boolean, etc.)
Type of collection (e.g.List[Int],TreeMap[Int, String], etc.)
Steppers exist to enable creating Java streams over Scala collections, seescala.jdk.StreamConverters.
Steppers exist to enable creating Java streams over Scala collections, seescala.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 methodshasStep 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 (java.util.Spliterator,java.util.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.
the element type of the Stepper
An implicit StepperShape instance is used in theIterableOnce.stepper to return a possibly specialized StepperS according to the element typeT.
An implicit StepperShape instance is used in theIterableOnce.stepper to return a possibly specialized StepperS according to the element typeT.
Trait that overrides iterable operations to take advantage of strict builders.
Trait that overrides iterable operations to take advantage of strict builders.
Elements type
Collection type
Collection type constructor
Trait that overrides map operations to take advantage of strict builders.
Trait that overrides map operations to take advantage of strict builders.
Collection type
Collection type constructor
Type of keys
Type of values
Trait that overrides operations on sequences in order to take advantage of strict builders.
Trait that overrides operations on sequences in order to take advantage of strict builders.
Trait that overrides set operations to take advantage of strict builders.
Trait that overrides set operations to take advantage of strict builders.
Elements type
Collection type
Collection type constructor
Trait that overrides sorted map operations to take advantage of strict builders.
Trait that overrides sorted map operations to take advantage of strict builders.
Collection type
Collection type constructor
Type of keys
Type of values
Trait that overrides sorted set operations to take advantage of strict builders.
Trait that overrides sorted set operations to take advantage of strict builders.
Elements type
Collection type
Collection type constructor
Provides extension methods for strings.
Provides extension methods for strings.
Some of these methods treat strings as a plain collection ofChars without any regard for Unicode handling. Unless the user takes Unicode handling in to account or makes sure the strings don't require such handling, these methods may result in unpaired or invalidly paired surrogate code units.
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. usingforeach orfoldLeft), or when the view is converted to a strict collection type (using theto operation).
This object reifies operations on views as case classes
This object reifies operations on views as case classes
A template trait that contains just themap,flatMap,foreach andwithFilter methods of traitIterable.
A template trait that contains just themap,flatMap,foreach andwithFilter methods of traitIterable.
Element type (e.g.Int)
Collection type constructor (e.g.List)
A default map which builds a defaultimmutable.Map implementation for all transformations.
A default map which builds a defaultimmutable.Map implementation for all transformations.
[Since version 2.13.0]DefaultMap is no longer necessary; extend Map directlyA 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 viaasScala andasJava:
scala.collection.Iterable <=> java.lang.Iterablescala.collection.Iterator <=> java.util.Iteratorscala.collection.mutable.Buffer <=> java.util.Listscala.collection.mutable.Set <=> java.util.Setscala.collection.mutable.Map <=> java.util.Mapscala.collection.concurrent.Map <=> java.util.concurrent.ConcurrentMapThe following conversions are supported viaasScala 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 viaasJava:
scala.collection.Seq => java.util.Listscala.collection.mutable.Seq => java.util.Listscala.collection.Set => java.util.Setscala.collection.Map => java.util.MapThe following one way conversion is provided viaasScala:
java.util.Properties => scala.collection.mutable.MapIn 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.asJavaval other: scala.collection.mutable.Buffer[Int] = target.asScalaassert(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> .toListres0: List[String] = List(hi, bye)scala> val ss = asScalaBuffer(vs)ss: scala.collection.mutable.Buffer[String] = Buffer(hi, bye)[Since version 2.13.0]Use `scala.jdk.CollectionConverters` instead[Since version 2.13.0]Use SeqOps (for the methods) or IndexedSeqOps (for fast indexed access) instead of ArrayLike[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Use SeqOps instead of SeqLike[Since version 2.13.0]Use Iterable instead of Traversable[Since version 2.13.0]Use IterableOnce instead of TraversableOnce[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Gen* collection types have been removed[Since version 2.13.0]Use Iterable instead of Traversable[Since version 2.13.0]Use IterableOnce instead of TraversableOnce