Packages

p

strawman

collection

package collection

A strawman architecture for new collections. It contains some example collection classes and methods with the intent to expose some key issues. It would be good to compare this to odether implementations of the same functionality, to get an idea of the strengths and weaknesses of different collection architectures.

For a test file, see tests/run/CollectionTests.scala.

Strawman6 is like strawman5, and adds lazy lists (i.e. lazie streams), arrays and some utilitity methods (take, tail, mkString, toArray). Also, systematically uses builders for all strict collections.

Types covered in this strawman:

  1. Collection base types:

IterableOnce, Iterable, Seq, LinearSeq, View, IndexedView

2. Collection creator base types:

FromIterable, IterableFactory, Buildable, Builder

3. Types that bundle operations:

IterableOps, IterableMonoTransforms, IterablePolyTransforms, IterableLike SeqMonoTransforms, SeqLike

4. Concrete collection types:

List, LazyList, ListBuffer, ArrayBuffer, ArrayBufferView, StringView, ArrayView

5. Decorators for existing types

StringOps, ArrayOps

6. Related non collection types:

Iterator, StringBuilder

Operations covered in this strawman:

  1. Abstract operations, or expected to be overridden:

For iterables:

iterator, fromIterable, fromIterableWithSameElemType, knownLength, className

For sequences:

apply, length

For buildables:

newBuilder

For builders:

+=, result

2. Utility methods, might be overridden for performance:

Operations returning not necessarily a collection:

foreach, foldLeft, foldRight, indexWhere, isEmpty, head, size, mkString

Operations returning a collection of a fixed type constructor:

view, to, toArray, copyToArray

Type-preserving generic transforms:

filter, partition, take, drop, tail, reverse

Generic transforms returning collections of different element types:

map, flatMap, ++, zip

Linear Supertypes
LowPriority, AnyRef, Any
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. trait ArrayLike [+A] extends Any

    A trait representing indexable collections with finite length

  2. final class ArrayOps [A] extends AnyVal with IterableOps[A] with SeqMonoTransforms[A, Array[A]] with Buildable[A, Array[A]] with ArrayLike[A]
  3. case class ArrayView [A](xs: Array[A]) extends IndexedView[A] with Product with Serializable
  4. trait BitSet extends SortedSet[Int] with BitSetLike[BitSet]

    Base type of bitsets

  5. trait BitSetFactories [+C] extends AnyRef

    Factory methods for unconstrained collections of kind *

  6. trait BitSetLike [+C <: BitSet] extends SortedSetLike[Int, SortedSet] with BitSetMonoTransforms[C]

    Base implementation type of bitsets

  7. trait BitSetMonoTransforms [+C <: BitSet] extends SetMonoTransforms[Int, C]
  8. trait FromIterable [+C[X] <: Iterable[X]] extends AnyRef

    Base trait for instances that can construct a collection from an iterable

  9. trait IndexedSeq [+A] extends Seq[A]
  10. trait IndexedView [+A] extends View[A] with ArrayLike[A]

    View defined in terms of indexing a range

  11. trait Iterable [+A] extends IterableOnce[A] with IterableLike[A, Iterable]

    Base trait for generic collections

  12. trait IterableFactories [+C[X] <: Iterable[X]] extends FromIterable[C]

    Base trait for companion objects of collections

  13. trait IterableLike [+A, +C[X] <: Iterable[X]] extends FromIterable[C] with IterableOps[A] with IterableMonoTransforms[A, C[A]] with IterablePolyTransforms[A, 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 IterableLike 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].

  14. trait IterableMonoTransforms [+A, +Repr] extends Any

    Type-preserving transforms over iterables.

    Type-preserving transforms over iterables. Operations defined here return in their result iterables of the same type as the one they are invoked on.

  15. trait IterableOnce [+A] extends AnyRef
  16. trait IterableOps [+A] extends Any

    Operations over iterables.

    Operations over iterables. No operation defined here is generic in the type of the underlying collection.

  17. trait IterablePolyTransforms [+A, +C[A]] extends Any

    Transforms over iterables that can return collections of different element types.

  18. trait Iterator [+A] extends IterableOnce[A]

    A core Iterator class

  19. trait LinearSeq [+A] extends Seq[A] with LinearSeqLike[A, LinearSeq]

    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

  20. trait LinearSeqLike [+A, +C[X] <: LinearSeq[X]] extends SeqLike[A, C]

    Base trait for linear Seq operations

  21. trait Map [K, +V] extends Iterable[(K, V)] with MapLike[K, V, Map]

    Base Map type

  22. trait MapFactories [C[_, _]] extends AnyRef

    Factory methods for collections of kind * −> * -> *

  23. trait MapLike [K, +V, +C[X, Y] <: Map[X, Y]] extends IterableLike[(K, V), Iterable] with IterableMonoTransforms[(K, V), C[K, V]] with MapPolyTransforms[K, V, C]

    Base Map implementation type

  24. trait MapPolyTransforms [K, +V, +C[X, Y] <: Map[X, Y]] extends IterablePolyTransforms[(K, V), Iterable]

    Polymorphic transformation methods

  25. trait OrderingGuidedFactories [C[_]] extends AnyRef

    Factories for collections whose elements require an ordering

  26. trait Seq [+A] extends Iterable[A] with SeqLike[A, Seq] with ArrayLike[A]

    Base trait for sequence collections

  27. trait SeqLike [+A, +C[X] <: Seq[X]] extends IterableLike[A, C] with SeqMonoTransforms[A, C[A]] with Equals

    Base trait for Seq operations

  28. trait SeqMonoTransforms [+A, +Repr] extends IterableMonoTransforms[A, Repr]

    Type-preserving transforms over sequences.

  29. trait Set [A] extends Iterable[A] with SetLike[A, Set]

    Base trait for set collections

  30. trait SetLike [A, +C[X] <: Set[X]] extends IterableLike[A, C] with SetMonoTransforms[A, C[A]] with Equals

    Base trait for set operations

  31. trait SetMonoTransforms [A, +Repr] extends IterableMonoTransforms[A, Repr]

    Monomorphic transformation operations

  32. trait Sorted [A] extends SortedLike[A, Sorted[A]]

    Base trait for sorted collections

  33. trait SortedLike [A, +Repr] extends AnyRef
  34. trait SortedPolyTransforms [A, +C[X] <: Sorted[X]] extends IterablePolyTransforms[A, Iterable]

    Polymorphic transformation methods on sorted collections

  35. trait SortedSet [A] extends Set[A] with Sorted[A] with SortedSetLike[A, SortedSet]

    Base type of sorted sets

  36. trait SortedSetLike [A, +C[X] <: SortedSet[X]] extends SortedLike[A, C[A]] with SortedPolyTransforms[A, C] with SetLike[A, Set] with SetMonoTransforms[A, C[A]]
  37. final class StringOps extends AnyVal with IterableOps[Char] with SeqMonoTransforms[Char, String] with IterablePolyTransforms[Char, List] with Buildable[Char, String] with ArrayLike[Char]
  38. case class StringView (s: String) extends IndexedView[Char] with Product with Serializable
  39. trait View [+A] extends Iterable[A] with IterableLike[A, View]

    Concrete collection type: View

  40. implicit final class toNewIterator [A] extends AnyVal
  41. implicit final class toNewSeq [A] extends AnyVal
  42. implicit final class toOldIterator [A] extends AnyVal
  43. implicit final class toOldSeq [A] extends AnyVal

Value Members

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

    Decorator to add collection operations to arrays.

  2. implicit def arrayToView[T](xs: Array[T]): ArrayView[T]

    Convert array to iterable via view.

    Convert array to iterable via view. Lower priority than ArrayOps

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

    Decorator to add collection operations to strings.

  4. implicit def stringToView(s: String): StringView

    Convert string to iterable via view.

    Convert string to iterable via view. Lower priority than StringOps

    Definition Classes
    LowPriority
  5. object IndexedView
  6. object Iterator
  7. object Seq
  8. object Set
  9. object View

    This object reifies operations on views as case classes

Inherited from LowPriority

Inherited from AnyRef

Inherited from Any

Ungrouped