strawman.collections

CollectionStrawMan6

Related Doc: package collections

object CollectionStrawMan6 extends LowPriority

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
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CollectionStrawMan6
  2. LowPriority
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. case class ::[+A](x: A, next: List[A]) extends List[A] with Product with Serializable

  2. class ArrayBuffer[A] extends Seq[A] with SeqLike[A, ArrayBuffer] with Buildable[A, ArrayBuffer[A]] with Builder[A, ArrayBuffer[A]]

    Concrete collection type: ArrayBuffer

  3. class ArrayBufferView[A] extends IndexedView[A]

  4. trait ArrayLike[+A] extends Any

    A trait representing indexable collections with finite length

  5. implicit final class ArrayOps[A] extends AnyVal with IterableOps[A] with SeqMonoTransforms[A, Array[A]] with Buildable[A, Array[A]] with ArrayLike[A]

    Decorator to add collection operations to arrays.

  6. case class ArrayView[A](xs: Array[A]) extends IndexedView[A] with Product with Serializable

  7. trait Buildable[+A, +Repr] extends IterableMonoTransforms[A, Repr]

    Base trait for strict collections that can be built using a builder.

  8. trait Builder[-A, +To] extends AnyRef

    Base trait for collection builders

  9. trait FromIterable[+C[X] <: Iterable[X]] extends AnyRef

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

  10. type IndexedSeq[+A] = Seq[A] { def view: strawman.collections.CollectionStrawMan6.IndexedView[A] }

  11. trait IndexedView[+A] extends View[A] with ArrayLike[A]

    View defined in terms of indexing a range

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

    Base trait for generic collections

  13. trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C]

    Base trait for companion objects of collections

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

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

  16. trait IterableOnce[+A] extends AnyRef

    Iterator can be used only once

  17. trait IterableOps[+A] extends Any

    Operations over iterables.

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

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

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

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

    A core Iterator class

  20. class LazyList[+A] extends LinearSeq[A] with SeqLike[A, LazyList]

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

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

    Base trait for linear Seq operations

  23. sealed trait List[+A] extends LinearSeq[A] with SeqLike[A, List] with Buildable[A, List[A]]

    Concrete collection type: List

  24. class ListBuffer[A] extends Seq[A] with SeqLike[A, ListBuffer] with Buildable[A, ListBuffer[A]] with Builder[A, ListBuffer[A]]

    Concrete collection type: ListBuffer

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

    Base trait for sequence collections

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

    Base trait for Seq operations

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

    Type-preserving transforms over sequences.

  28. class StringBuilder extends Builder[Char, String]

  29. implicit final class StringOps extends AnyVal with IterableOps[Char] with SeqMonoTransforms[Char, String] with IterablePolyTransforms[Char, List] with Buildable[Char, String] with ArrayLike[Char]

    Decorator to add collection operations to strings.

  30. case class StringView(s: String) extends IndexedView[Char] with Product with Serializable

  31. trait View[+A] extends Iterable[A] with IterableLike[A, View]

    Concrete collection type: View

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. object ArrayBuffer extends IterableFactory[ArrayBuffer]

  5. object IndexedView

  6. object Iterator

  7. object LazyList extends IterableFactory[LazyList]

  8. object List extends IterableFactory[List]

  9. object ListBuffer extends IterableFactory[ListBuffer]

  10. object Nil extends List[Nothing] with Product with Serializable

  11. object View

    This object reifies operations on views as case classes

  12. 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
  13. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  14. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  24. 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
  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  26. def toString(): String

    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LowPriority

Inherited from AnyRef

Inherited from Any

Ungrouped