Packages

p

scala

collection

package collection

Source
package.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. collection
  2. LowPriority
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractIterable[+A] extends Iterable[A]
  2. abstract class AbstractIterator[+A] extends Iterator[A]

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

  3. abstract class AbstractMap[A, +B] extends AbstractIterable[(A, B)] with Map[A, B]

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

  4. abstract class AbstractSeq[+A] extends AbstractIterable[A] with Seq[A]

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

  5. type AnyConstr[X] = Any

    Needed to circumvent a difficulty between dotty and scalac concerning the right top type for a type parameter of kind * -> *.

    Needed to circumvent a difficulty between dotty and scalac concerning the right top type for a type parameter of kind * -> *. In Scalac, we can provide Any, as Any is kind-polymorphic. In dotty this is not allowed. In dotty, we can provide [X] => Any. But Scalac does not know lambda syntax.

  6. final class ArrayOps[A] extends AnyVal

    This class serves as a wrapper for Arrays with many of the operations found in indexed sequences.

    This class serves as a wrapper for Arrays 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 an ArrayOps type. It is better to work with plain Array types instead and rely on the implicit conversion to ArrayOps when calling a method (which does not actually allocate an instance of ArrayOps because it is a value class).

    Neither Array nor ArrayOps are proper collection types (i.e. they do not extend Iterable or even IterableOnce). WrappedArray and ImmutableArray serve this purpose.

    The difference between this class and WrappedArray and ImmutableArray is that calling transformer methods such as filter and map will yield an array, whereas a WrappedArray will remain a WrappedArray.

    A

    type of the elements contained in this array.

    Since

    2.8

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

  8. trait BitSetOps[+C <: BitSet with BitSetOps[C]] extends SortedSetOps[Int, SortedSet, C]

    Base implementation type of bitsets

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

    Version

    2.8

    Since

    2.8

  10. trait BuildFrom[-From, -A, +C] extends Any

    Builds a collection of type C from elements of type A when a source collection of type From is available.

    Builds a collection of type C from elements of type A when a source collection of type From is available. Implicit instances of BuildFrom 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( msg = ... )
  11. trait BuildFromLowPriority extends AnyRef
  12. 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. ImmutableArray)

  13. trait ClassTagSeqFactory[+CC[_]] extends ClassTagIterableFactory[CC]

    CC

    Collection type constructor (e.g. WrappedArray)

  14. trait EvidenceIterableFactory[+CC[_], Ev[_]] extends AnyRef

    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. ImmutableArray)

    Ev

    Unary type constructor for the implicit evidence required for an element type (typically Ordering or ClassTag)

  15. trait Factory[-A, +C] extends Any

    A factory that builds a collection of type C with elements of type A.

    A factory that builds a collection of type C with elements of type A.

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

  16. trait IndexedSeq[+A] extends Seq[A] with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]]

    Base trait for indexed sequences that have efficient apply and length

  17. trait IndexedSeqOps[+A, +CC[_], +C] extends SeqOps[A, CC, C]

    Base trait for indexed Seq operations

  18. trait IndexedView[+A] extends IndexedSeqOps[A, View, View[A]] with SeqView[A]

    View defined in terms of indexing a range

  19. trait Iterable[+A] extends IterableOnce[A] with IterableOps[A, Iterable, Iterable[A]]

    Base trait for generic collections.

    Base trait for generic collections.

    A

    the element type of the collection

  20. trait IterableFactory[+CC[_]] extends AnyRef

    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)

  21. trait IterableOnce[+A] extends Any

    A template trait for collections which can be traversed either once only or one or more times.

  22. final class IterableOnceExtensionMethods[A] extends AnyVal
  23. trait IterableOnceOps[+A, +CC[_], +C] extends Any

    This implementation trait can be mixed into an IterableOnce to get the basic methods that are shared between Iterator and Iterable.

    This implementation trait can be mixed into an IterableOnce to get the basic methods that are shared between Iterator and Iterable. The IterableOnce must support multiple calls to iterator() but may or may not return the same Iterator every time.

  24. 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 to IterableOps are the same. We cannot express this since we lack variance polymorphism. That's why we have to resort at some places to write C[A @uncheckedVariance].

    CC

    type constructor of the collection (e.g. List, Set). Operations returning a collection with a different type of element B (e.g. map) return a CC[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 a C.

  25. 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 a next 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 and hasNext.

    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
    }
  26. final class LazyZip2[El1, El2, C1 <: Iterable[El1]] extends AnyRef

    Decorator representing lazily zipped pairs.

  27. final class LazyZip3[El1, El2, El3, C1 <: Iterable[El1]] extends AnyRef

    Decorator representing lazily zipped triples.

  28. final class LazyZip4[El1, El2, El3, El4, C1 <: Iterable[El1]] extends AnyRef

    Decorator representing lazily zipped 4-tuples.

  29. final class LazyZipOps[A, C1 <: Iterable[A]] extends AnyVal
  30. trait LinearSeq[+A] extends Seq[A] with LinearSeqOps[A, LinearSeq, LinearSeq[A]]

    Base trait for linearly accessed sequences that have efficient head and tail operations.

    Base trait for linearly accessed sequences that have efficient head and tail operations. Known subclasses: List, LazyList

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

  32. trait Map[K, +V] extends Iterable[(K, V)] with MapOps[K, V, Map, Map[K, V]] with Equals

    Base Map type

  33. trait MapFactory[+CC[_, _]] extends AnyRef

  34. 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 a CC[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 a C.

  35. trait MapView[K, +V] extends MapOps[K, V, [X, Y]View[(X, Y)], View[(K, V)]] with View[(K, V)]
  36. trait Seq[+A] extends Iterable[A] with PartialFunction[Int, A] with SeqOps[A, Seq, Seq[A]] with Equals

    Base trait for sequence collections

    Base trait for sequence collections

    A

    the element type of the collection

  37. trait SeqFactory[+CC[_]] extends IterableFactory[CC]

    CC

    Collection type constructor (e.g. List)

  38. 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 element B (e.g. map) return a CC[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 a C.

  39. trait SeqView[+A] extends SeqOps[A, View, View[A]] with View[A]
  40. trait Set[A] extends Iterable[A] with SetOps[A, Set, Set[A]] with Equals

    Base trait for set collections.

  41. trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]] extends IterableOps[A, CC, C] with (A) ⇒ Boolean

    Base trait for set operations

  42. 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)

  43. trait SortedMap[K, +V] extends Map[K, V] with SortedMapOps[K, V, SortedMap, SortedMap[K, V]]

    Base type of sorted sets

  44. trait SortedMapFactory[+CC[_, _]] extends AnyRef

  45. 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]
  46. trait SortedOps[A, +C] extends AnyRef

    Base trait for sorted collections

  47. trait SortedSet[A] extends Set[A] with SortedSetOps[A, SortedSet, SortedSet[A]]

    Base type of sorted sets

  48. trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]] extends SetOps[A, Set, C] with SortedOps[A, C]
  49. 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.)

  50. trait StrictOptimizedClassTagSeqFactory[+CC[_]] extends ClassTagSeqFactory[CC]
  51. trait StrictOptimizedIterableOps[+A, +CC[_], +C] extends IterableOps[A, CC, C]

    Trait that overrides operations to take advantage of strict builders.

    Trait that overrides operations to take advantage of strict builders.

    A

    Elements type

    C

    Collection type

  52. trait StrictOptimizedSeqFactory[+CC[_]] extends SeqFactory[CC]
  53. 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.

  54. trait StrictOptimizedSortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]] extends SortedSetOps[A, CC, C] with StrictOptimizedIterableOps[A, Set, C]
  55. final class StringOps extends AnyVal with IterableOnce[Char] with IndexedSeqOps[Char, collection.immutable.IndexedSeq, String] with StrictOptimizedIterableOps[Char, collection.immutable.IndexedSeq, String] with math.Ordered[String]
  56. case class StringView(s: String) extends IndexedView[Char] with Product with Serializable
  57. trait View[+A] extends Iterable[A] with IterableOps[A, View, View[A]]

    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 or foldLeft), or when the view is converted to a strict collection type (using the to operation).

  58. abstract class WithFilter[+A, +CC[_]] extends AnyRef

    A template trait that contains just the map, flatMap, foreach and withFilter methods of trait Iterable.

    A template trait that contains just the map, flatMap, foreach and withFilter methods of trait Iterable.

    A

    Element type (e.g. Int)

    CC

    Collection type constructor (e.g. List)

  59. final class toNewIterator[A] extends AnyVal
  60. final class toNewSeq[A] extends AnyVal
  61. final class toOldIterator[A] extends AnyVal
  62. final class toOldSeq[A] extends AnyVal
  63. 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

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

  65. type GenIterable[+X] = Iterable[X]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  66. type GenMap[K, +V] = Map[K, V]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  67. type GenSeq[+X] = Seq[X]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  68. type GenSet[X] = Set[X]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  69. type GenTraversable[+X] = Iterable[X]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  70. type GenTraversableOnce[+X] = IterableOnce[X]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  71. type SeqLike[A, T] = SeqOps[A, Seq, T]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use SeqOps instead of SeqLike

  72. type Traversable[+X] = Iterable[X]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use Iterable instead of Traversable

Value Members

  1. def arrayToArrayOps[A](as: Array[A]): ArrayOps[A]

    Decorator to add collection operations to arrays.

  2. def arrayToWrappedArray[T](xs: Array[T]): collection.mutable.IndexedSeq[T]

    Convert array to WrappedArray.

    Convert array to WrappedArray. Lower priority than ArrayOps

    Definition Classes
    LowPriority
  3. def optionToIterableOnce[A](maybeA: Option[A]): IterableOnce[A]
  4. def stringToSeq(s: String): WrappedString

    Convert String to Seq.

    Convert String to Seq. Lower priority than StringOps

    Definition Classes
    LowPriority
  5. def stringToStringOps(s: String): StringOps

    Decorator to add collection operations to strings.

  6. object +:

    An extractor used to head/tail deconstruct sequences.

  7. object :+

    An extractor used to init/last deconstruct sequences.

  8. object ArrayOps
  9. object BitSet extends SpecificIterableFactory[Int, BitSet]
  10. object BitSetOps
  11. object BuildFrom extends BuildFromLowPriority
  12. object ClassTagIterableFactory
  13. object ClassTagSeqFactory
  14. object EvidenceIterableFactory
  15. object Factory
  16. object Hashing
    Attributes
    protected
  17. object IndexedSeq extends Delegate[IndexedSeq]
  18. object IndexedView
  19. object Iterable extends Delegate[Iterable]
  20. object IterableFactory
  21. object IterableOnce
  22. object Iterator extends IterableFactory[Iterator]
  23. object JavaConverters extends DecorateAsJava with DecorateAsScala

    A variety of decorators that enable converting between Scala and Java collections using extension methods, asScala and asJava.

    A variety of decorators that enable converting between Scala and Java collections using extension methods, asScala and asJava.

    The extension methods return adapters for the corresponding API.

    The following conversions are supported via asScala and asJava:

    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] = non-empty iterator
    
    scala> .toList
    res0: List[String] = List(hi, bye)
    
    scala> val ss = asScalaBuffer(vs)
    ss: scala.collection.mutable.Buffer[String] = Buffer(hi, bye)
    Since

    2.8.1

  24. object LazyZip2
  25. object LazyZip3
  26. object LazyZip4
  27. object LinearSeq extends Delegate[LinearSeq]
  28. object Map extends Delegate[Map]

    This object provides a set of operations to create Map values.

  29. object MapFactory
  30. object MapView
  31. object Searching
  32. object Seq extends Delegate[Seq]

    This object provides a set of operations to create Seq values.

  33. object SeqFactory
  34. object SeqOps
  35. object SeqView
  36. object Set extends Delegate[Set]

    This object provides a set of operations to create Set values.

  37. object SortedIterableFactory
  38. object SortedMap extends Delegate[SortedMap]
  39. object SortedMapFactory
  40. object SortedSet extends Delegate[SortedSet]
  41. object StringOps
  42. object View extends IterableFactory[View]

    This object reifies operations on views as case classes

Deprecated Value Members

  1. val GenIterable: Iterable.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  2. val GenMap: Map.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  3. val GenSeq: Seq.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  4. val GenSet: Set.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  5. val GenTraversable: Iterable.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  6. val GenTraversableOnce: IterableOnce.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Gen* collection types have been removed

  7. val Traversable: Iterable.type
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use Iterable instead of Traversable

Inherited from LowPriority

Inherited from AnyRef

Inherited from Any

Ungrouped