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:
-
Collection base types:
IterableOnce, Iterable, Seq, LinearSeq, View, IndexedView
-
Collection creator base types:
FromIterable, IterableFactory, Buildable, Builder
-
Types that bundle operations:
IterableOps, IterableMonoTransforms, IterablePolyTransforms, IterableLike SeqMonoTransforms, SeqLike
-
Concrete collection types:
List, LazyList, ListBuffer, ArrayBuffer, ArrayBufferView, StringView, ArrayView
-
Decorators for existing types
StringOps, ArrayOps
-
Related non collection types:
Iterator, StringBuilder
Operations covered in this strawman:
-
Abstract operations, or expected to be overridden:
For iterables:
iterator, fromIterable, fromIterableWithSameElemType, knownLength, className
For sequences:
apply, length
For buildables:
newBuilder
For builders:
+=, result
-
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
Constructors
Members
Concrete collection type: ArrayBuffer
Concrete collection type: ArrayBuffer
A trait representing indexable collections with finite length
A trait representing indexable collections with finite length
Decorator to add collection operations to arrays.
Decorator to add collection operations to arrays.
Decorator to add collection operations to arrays.
Decorator to add collection operations to arrays.
Base trait for strict collections that can be built using a builder.
Base trait for strict collections that can be built using a builder.
Base trait for collection builders
Base trait for collection builders
Base trait for instances that can construct a collection from an iterable
Base trait for instances that can construct a collection from an iterable
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
Base trait for companion objects of collections
Base trait for companion objects of collections
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...
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]
.
Type-preserving transforms over iterables. Operations defined here return in their result iterables of the same type as the one they are invoked on.
Type-preserving transforms over iterables. Operations defined here return in their result iterables of the same type as the one they are invoked on.
Iterator can be used only once
Iterator can be used only once
Operations over iterables. No operation defined here is generic in the type of the underlying collection.
Operations over iterables. No operation defined here is generic in the type of the underlying collection.
Transforms over iterables that can return collections of different element types.
Transforms over iterables that can return collections of different element types.
A core Iterator class
A core Iterator class
Base trait for linearly accessed sequences that have efficient head
and
tail
operations.
Known subclasses: List, LazyList
Base trait for linearly accessed sequences that have efficient head
and
tail
operations.
Known subclasses: List, LazyList
Base trait for linear Seq operations
Base trait for linear Seq operations
Concrete collection type: List
Concrete collection type: List
Concrete collection type: ListBuffer
Concrete collection type: ListBuffer
Base trait for sequence collections
Base trait for sequence collections
Base trait for Seq operations
Base trait for Seq operations
Type-preserving transforms over sequences.
Type-preserving transforms over sequences.
Decorator to add collection operations to strings.
Decorator to add collection operations to strings.
Decorator to add collection operations to strings.
Decorator to add collection operations to strings.
This object reifies operations on views as case classes
This object reifies operations on views as case classes
Concrete collection type: View
Concrete collection type: View
Decorator to add collection operations to arrays.
Decorator to add collection operations to arrays.
Decorator to add collection operations to strings.
Decorator to add collection operations to strings.