scala

# collection

#### package collection

Contains the base traits and objects needed to use and extend Scala's collection library.

#### Guide

A detailed guide for the collections library is available at http://docs.scala-lang.org/overviews/collections/introduction.html.

#### Using Collections

It is convienient to treat all collections as either a scala.collection.Traversable or scala.collection.Iterable, as these traits define the vast majority of operations on a collection.

Collections can, of course, be treated as specifically as needed, and the library is designed to ensure that the methods that transform collections will return a collection of the same type:

    scala> val array = Array(1,2,3,4,5,6)
    array: Array[Int] = Array(1, 2, 3, 4, 5, 6)

    scala> array map { _.toString }
    res0: Array[java.lang.String] = Array(1, 2, 3, 4, 5, 6)

    scala> val list = List(1,2,3,4,5,6)
    list: List[Int] = List(1, 2, 3, 4, 5, 6)

    scala> list map { _.toString }
    res1: List[java.lang.String] = List(1, 2, 3, 4, 5, 6)

#### Creating Collections

The most common way to create a collection is to use the companion objects as factories. Of these, the three most common are scala.collection.Seq, scala.collection.immutable.Set, and scala.collection.immutable.Map. Their companion objects are all available as type aliases the either the scala package or in `scala.Predef`, and can be used like so:

    scala> val seq = Seq(1,2,3,4,1)
    seq: Seq[Int] = List(1, 2, 3, 4, 1)

    scala> val set = Set(1,2,3,4,1)
    set: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 4)

    scala> val map = Map(1 -> "one",2 -> "two", 3 -> "three",2 -> "too")
    map: scala.collection.immutable.Map[Int,java.lang.String] = Map((1,one), (2,too), (3,three))

It is also typical to use the scala.collection.immutable collections over those in scala.collection.mutable; The types aliased in the `scala.Predef` object are the immutable versions.

Also note that the collections library was carefully designed to include several implementations of each of the three basic collection types. These implementations have specific performance characteristics which are described in the guide.

##### Converting between Java Collections

The `JavaConversions` object provides implicit defs that will allow mostly seamless integration between Java Collections-based APIs and the Scala collections library.

Source
  package.scala

Linear Supertypes
AnyRef, Any
Content Hierarchy Learn more about scaladoc diagrams
Ordering

1. Alphabetic
2. By inheritance

Inherited

1. collection
2. AnyRef
3. Any

1. Hide All
2. Show all

Learn more about member selection
Visibility

1. Public
2. All

### Type Members

1. #### trait BitSet extends SortedSet[Int] with BitSetLike[BitSet]

   A common base class for mutable and immutable bitsets.

2. #### trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSetLike[Int, This]

   A template trait for bitsets.

3. #### trait BufferedIterator[+A] extends Iterator[A]

   Buffered iterators are iterators which provide a method `head` that inspects the next element without discarding it.

4. #### trait CustomParallelizable[+A, +ParRepr <: Parallel] extends Parallelizable[A, ParRepr]

5. #### trait DefaultMap[A, +B] extends Map[A, B]

   A default map which implements the `+` and `-` methods of maps.

6. #### trait GenIterable[+A] extends GenIterableLike[A, GenIterable[A]] with GenTraversable[A] with GenericTraversableTemplate[A, GenIterable]

   A trait for all iterable collections which may possibly have their operations implemented in parallel.

7. #### trait GenIterableLike[+A, +Repr] extends GenTraversableLike[A, Repr]

   A template trait for all iterable collections which may possibly have their operations implemented in parallel.

8. #### trait GenIterableView[+A, +Coll] extends GenIterableViewLike[A, Coll, GenIterableView[A, Coll]]

9. #### trait GenIterableViewLike[+A, +Coll, +This <: GenIterableView[A, Coll] with GenIterableViewLike[A, Coll, This]] extends GenIterable[A] with GenIterableLike[A, This] with GenTraversableView[A, Coll] with GenTraversableViewLike[A, Coll, This]

10. #### trait GenMap[A, +B] extends GenMapLike[A, B, GenMap[A, B]] with GenIterable[(A, B)]

    A trait for all traversable collections which may possibly have their operations implemented in parallel.

11. #### trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals with Parallelizable[(A, B), ParMap[A, B]]

    A trait for all maps upon which operations may be implemented in parallel.

12. #### trait GenSeq[+A] extends GenSeqLike[A, GenSeq[A]] with GenIterable[A] with Equals with GenericTraversableTemplate[A, GenSeq]

    A trait for all sequences which may possibly have their operations implemented in parallel.

13. #### trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Parallelizable[A, ParSeq[A]]

    A template trait for all sequences which may be traversed in parallel.

14. #### trait GenSeqView[+A, +Coll] extends GenSeqViewLike[A, Coll, GenSeqView[A, Coll]]

15. #### trait GenSeqViewLike[+A, +Coll, +This <: GenSeqView[A, Coll] with GenSeqViewLike[A, Coll, This]] extends GenSeq[A] with GenSeqLike[A, This] with GenIterableView[A, Coll] with GenIterableViewLike[A, Coll, This]

16. #### trait GenSet[A] extends GenSetLike[A, GenSet[A]] with GenIterable[A] with GenericSetTemplate[A, GenSet]

    A trait for sets which may possibly have their operations implemented in parallel.

17. #### trait GenSetLike[A, +Repr] extends GenIterableLike[A, Repr] with (A) ⇒ Boolean with Equals with Parallelizable[A, ParSet[A]]

    A template trait for sets which may possibly have their operations implemented in parallel.

18. #### trait GenTraversable[+A] extends GenTraversableLike[A, GenTraversable[A]] with GenTraversableOnce[A] with GenericTraversableTemplate[A, GenTraversable]

    A trait for all traversable collections which may possibly have their operations implemented in parallel.

19. #### trait GenTraversableLike[+A, +Repr] extends GenTraversableOnce[A] with Parallelizable[A, ParIterable[A]]

    A template trait for all traversable collections upon which operations may be implemented in parallel.

20. #### trait GenTraversableOnce[+A] extends Any

    A template trait for all traversable-once objects which may be traversed in parallel.

21. #### trait GenTraversableView[+A, +Coll] extends GenTraversableViewLike[A, Coll, GenTraversableView[A, Coll]]

22. #### trait GenTraversableViewLike[+A, +Coll, +This <: GenTraversableView[A, Coll] with GenTraversableViewLike[A, Coll, This]] extends GenTraversable[A] with GenTraversableLike[A, This]

23. #### trait IndexedSeq[+A] extends Seq[A] with GenericTraversableTemplate[A, IndexedSeq] with IndexedSeqLike[A, IndexedSeq[A]]

    A base trait for indexed sequences.

24. #### trait IndexedSeqLike[+A, +Repr] extends SeqLike[A, Repr]

    A template trait for indexed sequences of type `IndexedSeq[A]`.

25. #### trait IndexedSeqOptimized[+A, +Repr] extends IndexedSeqLike[A, Repr]

    A template trait for indexed sequences of type `IndexedSeq[A]` which optimizes the implementation of several methods under the assumption of fast random access.

26. #### trait Iterable[+A] extends Traversable[A] with GenIterable[A] with GenericTraversableTemplate[A, Iterable] with IterableLike[A, Iterable[A]]

    A base trait for iterable collections.

27. #### trait IterableLike[+A, +Repr] extends Equals with TraversableLike[A, Repr] with GenIterableLike[A, Repr]

    A template trait for iterable collections of type `Iterable[A]`.

28. #### trait IterableProxy[+A] extends Iterable[A] with IterableProxyLike[A, Iterable[A]]

    This trait implements a proxy for iterable objects.

29. #### trait IterableProxyLike[+A, +Repr <: IterableLike[A, Repr] with Iterable[A]] extends IterableLike[A, Repr] with TraversableProxyLike[A, Repr]

    This trait implements a proxy for Iterable objects.

30. #### trait IterableView[+A, +Coll] extends IterableViewLike[A, Coll, IterableView[A, Coll]] with GenIterableView[A, Coll]

    A base trait for non-strict views of `Iterable`s.

31. #### trait IterableViewLike[+A, +Coll, +This <: IterableView[A, Coll] with IterableViewLike[A, Coll, This]] extends Iterable[A] with IterableLike[A, This] with TraversableView[A, Coll] with TraversableViewLike[A, Coll, This] with GenIterableViewLike[A, Coll, This]

    A template trait for non-strict views of iterable collections.

32. #### trait Iterator[+A] extends TraversableOnce[A]

    Iterators are data structures that allow to iterate over a sequence of elements.

33. #### trait LinearSeq[+A] extends Seq[A] with GenericTraversableTemplate[A, LinearSeq] with LinearSeqLike[A, LinearSeq[A]]

    A base trait for linear sequences.

34. #### trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr]

    A template trait for linear sequences of type `LinearSeq[A]`.

35. #### trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends LinearSeqLike[A, Repr]

    A template trait for linear sequences of type `LinearSeq[A]` which optimizes the implementation of several methods under the assumption of fast linear access.

36. #### trait Map[A, +B] extends Iterable[(A, B)] with GenMap[A, B] with MapLike[A, B, Map[A, B]]

    A map from keys of type `A` to values of type `B`.

37. #### trait MapLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]] extends PartialFunction[A, B] with IterableLike[(A, B), This] with GenMapLike[A, B, This] with Subtractable[A, This] with Parallelizable[(A, B), ParMap[A, B]]

    A template trait for maps, which associate keys with values.

38. #### trait MapProxy[A, +B] extends Map[A, B] with MapProxyLike[A, B, Map[A, B]]

    This is a simple wrapper class for scala.collection.Map.

39. #### trait MapProxyLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]] extends MapLike[A, B, This] with IterableProxyLike[(A, B), This]

    This trait implements a proxy for Map objects.

40. #### trait Parallel extends AnyRef

    A marker trait for collections which have their operations parallelised.

41. #### trait Parallelizable[+A, +ParRepr <: Parallel] extends Any

    This trait describes collections which can be turned into parallel collections by invoking the method `par`.

42. #### trait Seq[+A] extends PartialFunction[Int, A] with Iterable[A] with GenSeq[A] with GenericTraversableTemplate[A, Seq] with SeqLike[A, Seq[A]]

    A base trait for sequences.

43. #### trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] with Parallelizable[A, ParSeq[A]]

    A template trait for sequences of type `Seq[A]`

44. #### trait SeqProxy[+A] extends Seq[A] with SeqProxyLike[A, Seq[A]]

    This trait implements a proxy for sequence objects.

45. #### trait SeqProxyLike[+A, +Repr <: SeqLike[A, Repr] with Seq[A]] extends SeqLike[A, Repr] with IterableProxyLike[A, Repr]

    This trait implements a proxy for sequences.

46. #### trait SeqView[+A, +Coll] extends SeqViewLike[A, Coll, SeqView[A, Coll]] with GenSeqView[A, Coll]

    A base trait for non-strict views of sequences.

47. #### trait SeqViewLike[+A, +Coll, +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, This]] extends Seq[A] with SeqLike[A, This] with IterableView[A, Coll] with IterableViewLike[A, Coll, This] with GenSeqViewLike[A, Coll, This]

    A template trait for non-strict views of sequences.

48. #### trait Set[A] extends (A) ⇒ Boolean with Iterable[A] with GenSet[A] with GenericSetTemplate[A, Set] with SetLike[A, Set[A]]

    A base trait for all sets, mutable as well as immutable.

49. #### trait SetLike[A, +This <: SetLike[A, This] with Set[A]] extends IterableLike[A, This] with GenSetLike[A, This] with Subtractable[A, This] with Parallelizable[A, ParSet[A]]

    A template trait for sets.

50. #### trait SetProxy[A] extends Set[A] with SetProxyLike[A, Set[A]]

    This is a simple wrapper class for scala.collection.Set.

51. #### trait SetProxyLike[A, +This <: SetLike[A, This] with Set[A]] extends SetLike[A, This] with IterableProxyLike[A, This]

    This trait implements a proxy for sets.

52. #### trait SortedMap[A, +B] extends Map[A, B] with SortedMapLike[A, B, SortedMap[A, B]]

    A map whose keys are sorted.

53. #### trait SortedMapLike[A, +B, +This <: SortedMapLike[A, B, This] with SortedMap[A, B]] extends Sorted[A, This] with MapLike[A, B, This]

    A template for maps whose keys are sorted.

54. #### trait SortedSet[A] extends Set[A] with SortedSetLike[A, SortedSet[A]]

    A sorted set.

55. #### trait SortedSetLike[A, +This <: SortedSet[A] with SortedSetLike[A, This]] extends Sorted[A, This] with SetLike[A, This]

    A template for sets which are sorted.

56. #### trait Traversable[+A] extends TraversableLike[A, Traversable[A]] with GenTraversable[A] with TraversableOnce[A] with GenericTraversableTemplate[A, Traversable]

    A trait for traversable collections.

57. #### trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] with FilterMonadic[A, Repr] with TraversableOnce[A] with GenTraversableLike[A, Repr] with Parallelizable[A, ParIterable[A]]

    A template trait for traversable collections of type `Traversable[A]`.

58. #### trait TraversableOnce[+A] extends GenTraversableOnce[A]

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

59. #### trait TraversableProxy[+A] extends Traversable[A] with TraversableProxyLike[A, Traversable[A]]

    This trait implements a proxy for traversable objects.

60. #### trait TraversableProxyLike[+A, +Repr <: TraversableLike[A, Repr] with Traversable[A]] extends TraversableLike[A, Repr] with Proxy

    This trait implements a proxy for Traversable objects.

61. #### trait TraversableView[+A, +Coll] extends TraversableViewLike[A, Coll, TraversableView[A, Coll]] with GenTraversableView[A, Coll]

    A base trait for non-strict views of traversable collections.

62. #### trait TraversableViewLike[+A, +Coll, +This <: TraversableView[A, Coll] with TraversableViewLike[A, Coll, This]] extends Traversable[A] with TraversableLike[A, This] with ViewMkString[A] with GenTraversableViewLike[A, Coll, This]

    A template trait for non-strict views of traversable collections.

63. #### trait ViewMkString[+A] extends AnyRef

### Value Members

1. #### object +:

   An extractor used to head/tail deconstruct sequences.

2. #### object :+

   An extractor used to init/last deconstruct sequences.

3. #### object BitSet extends BitSetFactory[BitSet]

   This object provides a set of operations to create ``BitSet`` values.

4. #### object BitSetLike

   Companion object for BitSets.

5. #### object GenIterable extends GenTraversableFactory[GenIterable]

6. #### object GenMap extends GenMapFactory[GenMap]

7. #### object GenSeq extends GenTraversableFactory[GenSeq]

8. #### object GenSet extends GenTraversableFactory[GenSet]

9. #### object GenTraversable extends GenTraversableFactory[GenTraversable]

10. #### object IndexedSeq extends SeqFactory[IndexedSeq]

    This object provides a set of operations to create ``IndexedSeq`` values.

11. #### object Iterable extends GenTraversableFactory[Iterable] with TraversableFactory[Iterable]

    This object provides a set of operations to create ``Iterable`` values.

12. #### object IterableView

    An object containing the necessary implicit definitions to make `IterableView`s work.

13. #### object Iterator

    The `Iterator` object provides various functions for creating specialized iterators.

14. #### object JavaConversions extends WrapAsScala with WrapAsJava

    A collection of implicit conversions supporting interoperability between Scala and Java collections.

15. #### object JavaConverters extends DecorateAsJava with DecorateAsScala

    A collection of decorators that allow converting between Scala and Java collections using `asScala` and `asJava` methods.

16. #### object LinearSeq extends SeqFactory[LinearSeq]

    This object provides a set of operations to create ``LinearSeq`` values.

17. #### object Map extends MapFactory[Map]

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

18. #### object Seq extends SeqFactory[Seq]

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

19. #### object SeqLike

    The companion object for trait `SeqLike`.

20. #### object SeqView

    An object containing the necessary implicit definitions to make `SeqView`s work.

21. #### object Set extends SetFactory[Set]

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

22. #### object SortedMap extends SortedMapFactory[SortedMap]

23. #### object SortedSet extends SortedSetFactory[SortedSet]

24. #### object Traversable extends GenTraversableFactory[Traversable] with TraversableFactory[Traversable]

    This object provides a set of operations to create `Traversable` values.

25. #### object TraversableOnce

26. #### object TraversableView

    An object containing the necessary implicit definitions to make `TraversableView`s work.

27. #### def breakOut[From, T, To](implicit b: CanBuildFrom[Nothing, T, To]): CanBuildFrom[From, T, To]

    Provides a CanBuildFrom instance that builds a specific target collection (`To') irrespective of the original collection (`From').

28. #### package concurrent

29. #### package convert

30. #### package generic

31. #### package immutable

32. #### package mutable

33. #### package parallel

    Package object for parallel collections.

34. #### package script

### Inherited from AnyRef

### Inherited from Any

### Ungrouped