summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-09-25 16:20:13 +0000
committerMartin Odersky <odersky@gmail.com>2009-09-25 16:20:13 +0000
commit4a727f3b01d0fa27ef51f7dba472116e021e3445 (patch)
treec9ab55ea7fe6051455271b23e9fbfc2f313015c0
parente31f18094dfba97c80871869a037172ff2c9c1c2 (diff)
downloadscala-4a727f3b01d0fa27ef51f7dba472116e021e3445.tar.gz
scala-4a727f3b01d0fa27ef51f7dba472116e021e3445.tar.bz2
scala-4a727f3b01d0fa27ef51f7dba472116e021e3445.zip
Collections refactoring.
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala5
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
-rw-r--r--src/library/scala/Enumeration.scala8
-rw-r--r--src/library/scala/LowPriorityImplicits.scala41
-rw-r--r--src/library/scala/Predef.scala40
-rw-r--r--src/library/scala/Range.scala2
-rw-r--r--src/library/scala/Unhashable.scala44
-rw-r--r--src/library/scala/collection/BitSet.scala2
-rw-r--r--src/library/scala/collection/BitSetLike.scala (renamed from src/library/scala/collection/generic/BitSetTemplate.scala)9
-rw-r--r--src/library/scala/collection/Iterable.scala12
-rw-r--r--src/library/scala/collection/IterableProxy.scala2
-rw-r--r--src/library/scala/collection/IterableProxyLike.scala (renamed from src/library/scala/collection/generic/IterableProxyTemplate.scala)14
-rw-r--r--src/library/scala/collection/IterableView.scala (renamed from src/library/scala/collection/generic/IterableView.scala)6
-rw-r--r--src/library/scala/collection/IterableViewLike.scala (renamed from src/library/scala/collection/generic/IterableViewTemplate.scala)16
-rw-r--r--src/library/scala/collection/JavaConversions.scala4
-rw-r--r--src/library/scala/collection/LinearSequence.scala7
-rw-r--r--src/library/scala/collection/LinearSequenceLike.scala2
-rw-r--r--src/library/scala/collection/Map.scala4
-rw-r--r--src/library/scala/collection/MapLike.scala (renamed from src/library/scala/collection/generic/MapTemplate.scala)13
-rw-r--r--src/library/scala/collection/MapProxy.scala4
-rw-r--r--src/library/scala/collection/MapProxyLike.scala (renamed from src/library/scala/collection/generic/MapProxyTemplate.scala)13
-rw-r--r--src/library/scala/collection/Sequence.scala9
-rw-r--r--src/library/scala/collection/SequenceLike.scala88
-rw-r--r--src/library/scala/collection/SequenceProxy.scala5
-rw-r--r--src/library/scala/collection/SequenceProxyLike.scala (renamed from src/library/scala/collection/generic/SequenceProxyTemplate.scala)9
-rw-r--r--src/library/scala/collection/SequenceView.scala (renamed from src/library/scala/collection/generic/SequenceView.scala)6
-rw-r--r--src/library/scala/collection/SequenceViewLike.scala (renamed from src/library/scala/collection/generic/SequenceViewTemplate.scala)16
-rw-r--r--src/library/scala/collection/Set.scala6
-rw-r--r--src/library/scala/collection/SetLike.scala (renamed from src/library/scala/collection/generic/SetTemplate.scala)14
-rw-r--r--src/library/scala/collection/SetProxy.scala4
-rw-r--r--src/library/scala/collection/SetProxyLike.scala (renamed from src/library/scala/collection/generic/SetProxyTemplate.scala)9
-rw-r--r--src/library/scala/collection/SortedMap.scala3
-rw-r--r--src/library/scala/collection/SortedMapLike.scala (renamed from src/library/scala/collection/generic/SortedMapTemplate.scala)9
-rw-r--r--src/library/scala/collection/SortedSet.scala4
-rw-r--r--src/library/scala/collection/SortedSetLike.scala (renamed from src/library/scala/collection/generic/SortedSetTemplate.scala)6
-rw-r--r--src/library/scala/collection/Traversable.scala13
-rw-r--r--src/library/scala/collection/TraversableLike.scala2
-rw-r--r--src/library/scala/collection/TraversableProxy.scala6
-rw-r--r--src/library/scala/collection/TraversableProxyLike.scala (renamed from src/library/scala/collection/generic/TraversableProxyTemplate.scala)16
-rw-r--r--src/library/scala/collection/TraversableView.scala (renamed from src/library/scala/collection/generic/TraversableView.scala)7
-rw-r--r--src/library/scala/collection/TraversableViewLike.scala (renamed from src/library/scala/collection/generic/TraversableViewTemplate.scala)15
-rw-r--r--src/library/scala/collection/Vector.scala8
-rw-r--r--src/library/scala/collection/VectorLike.scala2
-rw-r--r--src/library/scala/collection/VectorView.scala (renamed from src/library/scala/collection/generic/VectorView.scala)6
-rw-r--r--src/library/scala/collection/VectorViewLike.scala (renamed from src/library/scala/collection/generic/VectorViewTemplate.scala)17
-rw-r--r--src/library/scala/collection/generic/Addable.scala4
-rw-r--r--src/library/scala/collection/generic/BitSetFactory.scala6
-rw-r--r--src/library/scala/collection/generic/BuilderFactory.scala6
-rw-r--r--src/library/scala/collection/generic/GenericCompanion.scala (renamed from src/library/scala/collection/generic/Companion.scala)7
-rw-r--r--src/library/scala/collection/generic/GenericSetTemplate.scala (renamed from src/library/scala/collection/generic/SetClass.scala)6
-rw-r--r--src/library/scala/collection/generic/GenericTraversableTemplate.scala (renamed from src/library/scala/collection/generic/TraversableClass.scala)9
-rw-r--r--src/library/scala/collection/generic/Growable.scala4
-rw-r--r--src/library/scala/collection/generic/ImmutableMapFactory.scala8
-rw-r--r--src/library/scala/collection/generic/ImmutableSortedMapFactory.scala8
-rw-r--r--src/library/scala/collection/generic/ImmutableSortedSetFactory.scala8
-rw-r--r--src/library/scala/collection/generic/IterableTemplate.scala42
-rw-r--r--src/library/scala/collection/generic/KMP.scala90
-rw-r--r--src/library/scala/collection/generic/LinearSequenceTemplate.scala32
-rw-r--r--src/library/scala/collection/generic/MapFactory.scala8
-rw-r--r--src/library/scala/collection/generic/MutableMapFactory.scala8
-rw-r--r--src/library/scala/collection/generic/MutableVectorTemplate.scala43
-rw-r--r--src/library/scala/collection/generic/SequenceFactory.scala7
-rw-r--r--src/library/scala/collection/generic/SequenceTemplate.scala34
-rw-r--r--src/library/scala/collection/generic/SetFactory.scala10
-rw-r--r--src/library/scala/collection/generic/Shrinkable.scala4
-rw-r--r--src/library/scala/collection/generic/Sorted.scala4
-rw-r--r--src/library/scala/collection/generic/SortedMapFactory.scala8
-rw-r--r--src/library/scala/collection/generic/SortedSetFactory.scala8
-rw-r--r--src/library/scala/collection/generic/Subtractable.scala4
-rw-r--r--src/library/scala/collection/generic/TraversableFactory.scala8
-rw-r--r--src/library/scala/collection/generic/TraversableTemplate.scala62
-rw-r--r--src/library/scala/collection/generic/VectorTemplate.scala23
-rw-r--r--src/library/scala/collection/immutable/BitSet.scala11
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala10
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala12
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala5
-rw-r--r--src/library/scala/collection/immutable/Iterable.scala17
-rw-r--r--src/library/scala/collection/immutable/LinearSequence.scala15
-rw-r--r--src/library/scala/collection/immutable/List.scala26
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala7
-rw-r--r--src/library/scala/collection/immutable/ListSet.scala11
-rw-r--r--src/library/scala/collection/immutable/LongMap.scala5
-rw-r--r--src/library/scala/collection/immutable/Map.scala9
-rw-r--r--src/library/scala/collection/immutable/MapLike.scala (renamed from src/library/scala/collection/generic/ImmutableMapTemplate.scala)11
-rw-r--r--src/library/scala/collection/immutable/MapProxy.scala7
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala5
-rw-r--r--src/library/scala/collection/immutable/Queue.scala3
-rw-r--r--src/library/scala/collection/immutable/RedBlack.scala3
-rw-r--r--src/library/scala/collection/immutable/Sequence.scala15
-rw-r--r--src/library/scala/collection/immutable/Set.scala13
-rw-r--r--src/library/scala/collection/immutable/SetProxy.scala7
-rw-r--r--src/library/scala/collection/immutable/SortedMap.scala14
-rw-r--r--src/library/scala/collection/immutable/SortedSet.scala8
-rw-r--r--src/library/scala/collection/immutable/Stack.scala5
-rw-r--r--src/library/scala/collection/immutable/Stream.scala21
-rw-r--r--src/library/scala/collection/immutable/StringLike.scala3
-rw-r--r--src/library/scala/collection/immutable/Traversable.scala15
-rw-r--r--src/library/scala/collection/immutable/TreeHashMap.scala5
-rw-r--r--src/library/scala/collection/immutable/TreeMap.scala10
-rw-r--r--src/library/scala/collection/immutable/TreeSet.scala8
-rw-r--r--src/library/scala/collection/immutable/Vector.scala15
-rw-r--r--src/library/scala/collection/immutable/WrappedString.scala3
-rw-r--r--src/library/scala/collection/interfaces/IterableMethods.scala6
-rw-r--r--src/library/scala/collection/interfaces/MapMethods.scala6
-rw-r--r--src/library/scala/collection/interfaces/SequenceMethods.scala6
-rw-r--r--src/library/scala/collection/interfaces/SetMethods.scala6
-rw-r--r--src/library/scala/collection/interfaces/TraversableMethods.scala6
-rw-r--r--src/library/scala/collection/mutable/AddingBuilder.scala (renamed from src/library/scala/collection/generic/AddingBuilder.scala)8
-rw-r--r--src/library/scala/collection/mutable/ArrayBuffer.scala15
-rw-r--r--src/library/scala/collection/mutable/ArrayBuilder.scala6
-rw-r--r--src/library/scala/collection/mutable/ArrayLike.scala2
-rw-r--r--src/library/scala/collection/mutable/ArrayOps.scala2
-rw-r--r--src/library/scala/collection/mutable/ArrayStack.scala9
-rw-r--r--src/library/scala/collection/mutable/BitSet.scala14
-rw-r--r--src/library/scala/collection/mutable/Buffer.scala11
-rw-r--r--src/library/scala/collection/mutable/BufferLike.scala (renamed from src/library/scala/collection/generic/BufferTemplate.scala)18
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala21
-rw-r--r--src/library/scala/collection/mutable/Builder.scala (renamed from src/library/scala/collection/generic/Builder.scala)8
-rw-r--r--src/library/scala/collection/mutable/Cloneable.scala (renamed from src/library/scala/collection/generic/Cloneable.scala)4
-rw-r--r--src/library/scala/collection/mutable/CloneableCollection.scala3
-rw-r--r--src/library/scala/collection/mutable/DefaultEntry.scala3
-rw-r--r--src/library/scala/collection/mutable/DefaultMapModel.scala3
-rw-r--r--src/library/scala/collection/mutable/DoubleLinkedList.scala11
-rw-r--r--src/library/scala/collection/mutable/DoubleLinkedListLike.scala (renamed from src/library/scala/collection/generic/DoubleLinkedListTemplate.scala)6
-rw-r--r--src/library/scala/collection/mutable/FlatHashTable.scala3
-rw-r--r--src/library/scala/collection/mutable/GenericArray.scala11
-rw-r--r--src/library/scala/collection/mutable/HashEntry.scala3
-rw-r--r--src/library/scala/collection/mutable/HashMap.scala7
-rw-r--r--src/library/scala/collection/mutable/HashSet.scala11
-rw-r--r--src/library/scala/collection/mutable/HashTable.scala5
-rw-r--r--src/library/scala/collection/mutable/History.scala3
-rw-r--r--src/library/scala/collection/mutable/ImmutableMapAdaptor.scala4
-rw-r--r--src/library/scala/collection/mutable/Iterable.scala13
-rw-r--r--src/library/scala/collection/mutable/LazyBuilder.scala (renamed from src/library/scala/collection/generic/LazyBuilder.scala)11
-rw-r--r--src/library/scala/collection/mutable/LinearSequence.scala13
-rw-r--r--src/library/scala/collection/mutable/LinkedEntry.scala3
-rw-r--r--src/library/scala/collection/mutable/LinkedHashMap.scala7
-rw-r--r--src/library/scala/collection/mutable/LinkedHashSet.scala11
-rw-r--r--src/library/scala/collection/mutable/LinkedList.scala11
-rw-r--r--src/library/scala/collection/mutable/LinkedListLike.scala (renamed from src/library/scala/collection/generic/LinkedListTemplate.scala)8
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala14
-rw-r--r--src/library/scala/collection/mutable/ListMap.scala7
-rw-r--r--src/library/scala/collection/mutable/Map.scala12
-rw-r--r--src/library/scala/collection/mutable/MapBuilder.scala (renamed from src/library/scala/collection/generic/MapBuilder.scala)8
-rw-r--r--src/library/scala/collection/mutable/MapLike.scala (renamed from src/library/scala/collection/generic/MutableMapTemplate.scala)14
-rw-r--r--src/library/scala/collection/mutable/MapLikeBase.scala (renamed from src/library/scala/collection/generic/MutableMapTemplateBase.scala)10
-rw-r--r--src/library/scala/collection/mutable/MapProxy.scala7
-rw-r--r--src/library/scala/collection/mutable/MultiMap.scala3
-rw-r--r--src/library/scala/collection/mutable/MutableList.scala7
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala5
-rw-r--r--src/library/scala/collection/mutable/ObservableMap.scala5
-rw-r--r--src/library/scala/collection/mutable/ObservableSet.scala5
-rw-r--r--src/library/scala/collection/mutable/OpenHashMap.scala3
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala7
-rw-r--r--src/library/scala/collection/mutable/PriorityQueueProxy.scala5
-rw-r--r--src/library/scala/collection/mutable/Publisher.scala3
-rw-r--r--src/library/scala/collection/mutable/Queue.scala5
-rw-r--r--src/library/scala/collection/mutable/QueueProxy.scala5
-rw-r--r--src/library/scala/collection/mutable/ResizableArray.scala11
-rw-r--r--src/library/scala/collection/mutable/RevertibleHistory.scala3
-rw-r--r--src/library/scala/collection/mutable/Sequence.scala14
-rw-r--r--src/library/scala/collection/mutable/Set.scala14
-rw-r--r--src/library/scala/collection/mutable/SetBuilder.scala (renamed from src/library/scala/collection/generic/SetBuilder.scala)8
-rw-r--r--src/library/scala/collection/mutable/SetLike.scala (renamed from src/library/scala/collection/generic/MutableSetTemplate.scala)15
-rw-r--r--src/library/scala/collection/mutable/SetProxy.scala7
-rw-r--r--src/library/scala/collection/mutable/Stack.scala11
-rw-r--r--src/library/scala/collection/mutable/StackProxy.scala7
-rw-r--r--src/library/scala/collection/mutable/StringBuilder.scala5
-rw-r--r--src/library/scala/collection/mutable/Subscriber.scala3
-rw-r--r--src/library/scala/collection/mutable/SynchronizedBuffer.scala7
-rw-r--r--src/library/scala/collection/mutable/SynchronizedMap.scala7
-rw-r--r--src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala5
-rw-r--r--src/library/scala/collection/mutable/SynchronizedQueue.scala5
-rw-r--r--src/library/scala/collection/mutable/SynchronizedSet.scala9
-rw-r--r--src/library/scala/collection/mutable/SynchronizedStack.scala7
-rw-r--r--src/library/scala/collection/mutable/Traversable.scala13
-rw-r--r--src/library/scala/collection/mutable/Undoable.scala3
-rw-r--r--src/library/scala/collection/mutable/Vector.scala13
-rw-r--r--src/library/scala/collection/mutable/VectorLike.scala4
-rw-r--r--src/library/scala/collection/mutable/VectorView.scala (renamed from src/library/scala/collection/generic/MutableVectorView.scala)14
-rw-r--r--src/library/scala/collection/mutable/VectorViewLike.scala (renamed from src/library/scala/collection/generic/MutableVectorViewTemplate.scala)14
-rw-r--r--src/library/scala/collection/mutable/WeakHashMap.scala5
-rw-r--r--src/library/scala/collection/mutable/WrappedArray.scala25
-rw-r--r--src/library/scala/collection/mutable/WrappedArrayBuilder.scala5
-rw-r--r--src/library/scala/collection/script/Location.scala3
-rw-r--r--src/library/scala/collection/script/Message.scala4
-rw-r--r--src/library/scala/collection/script/Scriptable.scala3
-rw-r--r--src/library/scala/runtime/BoxedArray.scala5
-rw-r--r--src/library/scala/runtime/RichChar.scala3
-rw-r--r--src/library/scala/runtime/RichString.scala5
-rw-r--r--src/library/scala/xml/NodeSeq.scala7
-rw-r--r--test/files/neg/bug876.check2
-rw-r--r--test/files/neg/t2031.check2
-rw-r--r--test/files/pos/spec-List.scala34
-rw-r--r--test/files/run/t2074_2.check4
-rw-r--r--test/files/run/t2074_2.scala5
198 files changed, 945 insertions, 1093 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 1cd7842fd4..f03b7d5096 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -386,9 +386,10 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
localTyper.typedPos(pos) {
val predef = gen.mkAttributedRef(PredefModule)
val meth =
- if ((elemtp <:< AnyRefClass.tpe) && !isPhantomClass(elemtp.typeSymbol) ||
- isValueClass(elemtp.typeSymbol))
- Select(predef, "wrapArray")
+ if ((elemtp <:< AnyRefClass.tpe) && !isPhantomClass(elemtp.typeSymbol))
+ Select(predef, "wrapRefArray")
+ else if (isValueClass(elemtp.typeSymbol))
+ Select(predef, "wrap"+elemtp.typeSymbol.name+"Array")
else
TypeApply(Select(predef, "genericWrapArray"), List(TypeTree(elemtp)))
Apply(meth, List(tree))
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index a6e6aedea6..90af1e479b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -310,10 +310,11 @@ self: Analyzer =>
try {
val itree1 =
if (isView)
- typed1(
+ typed1 (
atPos(itree.pos) (
Apply(itree, List(Ident("<argument>").setType(approximate(pt.typeArgs.head))))),
- EXPRmode, approximate(pt.typeArgs.tail.head))
+ EXPRmode, approximate(pt.typeArgs.tail.head)
+ )
else
typed1(itree, EXPRmode, wildPt)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index f7829208b1..737af2d36e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -166,7 +166,7 @@ trait Infer {
// this can happen if during solving a cyclic type paramater
// such as T <: T gets completed. See #360
tvar.constr.inst = ErrorType
- } else assert(false, tvar.origin)
+ } else assert(false, tvar.origin+" at "+tvar.origin.typeSymbol.owner)
tvars map instantiate
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 90e263587c..1943fcc1a4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -237,7 +237,14 @@ trait Typers { self: Analyzer =>
else to.typeSymbol.newValue(tree.pos, name)
psym = to.decls enter psym
psym setInfo tp
+ try {
inferView(tree, from, to, true)
+ } catch {
+ case ex: AssertionError =>
+ println("infer view "+tree+" "+name+" "+context.undetparams)
+ throw ex
+ }
+
}
import infer._
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 81903afe82..8de201ec9a 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -11,10 +11,10 @@
package scala
-
-import scala.collection.mutable.{Map, HashMap}
+import scala.collection.SetLike
+import scala.collection.mutable.{Builder, AddingBuilder, Map, HashMap}
import scala.collection.immutable.{Set, BitSet}
-import scala.collection.generic.{Builder, BuilderFactory, AddingBuilder, SetTemplate}
+import scala.collection.generic.BuilderFactory
/** <p>
* Defines a finite set of values specific to the enumeration. Typically
@@ -213,7 +213,7 @@ abstract class Enumeration(initial: Int, names: String*) {
* Iterating through this set will yield values in increasing order of their ids.
* @param ids The set of ids of values, organized as a BitSet.
*/
- class ValueSet private[Enumeration] (val ids: BitSet) extends Set[Value] with SetTemplate[Value, ValueSet] {
+ class ValueSet private[Enumeration] (val ids: BitSet) extends Set[Value] with SetLike[Value, ValueSet] {
override def empty = ValueSet.empty
def contains(v: Value) = ids contains (v.id)
def + (value: Value) = new ValueSet(ids + value.id)
diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala
index 5334dca078..d52101736c 100644
--- a/src/library/scala/LowPriorityImplicits.scala
+++ b/src/library/scala/LowPriorityImplicits.scala
@@ -12,7 +12,8 @@
package scala
import collection.mutable._
-import collection.immutable.WrappedString
+import collection.immutable.{WrappedString, Vector}
+import collection.generic.BuilderFactory
/** The `LowPriorityImplicits` class provides implicit values that
* are valid in all Scala compilation units without explicit qualification,
@@ -27,18 +28,36 @@ class LowPriorityImplicits {
implicit def genericWrapArray[T](xs: Array[T]): WrappedArray[T] =
WrappedArray.make(xs)
- implicit def wrapArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = new WrappedArray.ofRef[T](xs)
- implicit def wrapArray(xs: Array[Int]): WrappedArray[Int] = new WrappedArray.ofInt(xs)
- implicit def wrapArray(xs: Array[Double]): WrappedArray[Double] = new WrappedArray.ofDouble(xs)
- implicit def wrapArray(xs: Array[Long]): WrappedArray[Long] = new WrappedArray.ofLong(xs)
- implicit def wrapArray(xs: Array[Float]): WrappedArray[Float] = new WrappedArray.ofFloat(xs)
- implicit def wrapArray(xs: Array[Char]): WrappedArray[Char] = new WrappedArray.ofChar(xs)
- implicit def wrapArray(xs: Array[Byte]): WrappedArray[Byte] = new WrappedArray.ofByte(xs)
- implicit def wrapArray(xs: Array[Short]): WrappedArray[Short] = new WrappedArray.ofShort(xs)
- implicit def wrapArray(xs: Array[Boolean]): WrappedArray[Boolean] = new WrappedArray.ofBoolean(xs)
- implicit def wrapArray(xs: Array[Unit]): WrappedArray[Unit] = new WrappedArray.ofUnit(xs)
+ implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = new WrappedArray.ofRef[T](xs)
+ implicit def wrapIntArray(xs: Array[Int]): WrappedArray[Int] = new WrappedArray.ofInt(xs)
+ implicit def wrapDoubleArray(xs: Array[Double]): WrappedArray[Double] = new WrappedArray.ofDouble(xs)
+ implicit def wrapLongArray(xs: Array[Long]): WrappedArray[Long] = new WrappedArray.ofLong(xs)
+ implicit def wrapFloatArray(xs: Array[Float]): WrappedArray[Float] = new WrappedArray.ofFloat(xs)
+ implicit def wrapCharArray(xs: Array[Char]): WrappedArray[Char] = new WrappedArray.ofChar(xs)
+ implicit def wrapByteArray(xs: Array[Byte]): WrappedArray[Byte] = new WrappedArray.ofByte(xs)
+ implicit def wrapShortArray(xs: Array[Short]): WrappedArray[Short] = new WrappedArray.ofShort(xs)
+ implicit def wrapBooleanArray(xs: Array[Boolean]): WrappedArray[Boolean] = new WrappedArray.ofBoolean(xs)
+ implicit def wrapUnitArray(xs: Array[Unit]): WrappedArray[Unit] = new WrappedArray.ofUnit(xs)
implicit def wrapString(s: String): WrappedString = new WrappedString(s)
implicit def unwrapString(ws: WrappedString): String = ws.self
+ implicit def fallbackStringBuilderFactory[T]: BuilderFactory[T, collection.immutable.Vector[T], String] =
+ new BuilderFactory[T, collection.immutable.Vector[T], String] {
+ def apply(from: String) = scala.collection.immutable.Vector.newBuilder[T]
+ }
+
+ /** Can go away after next newstarr */
+ def wrapArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = new WrappedArray.ofRef[T](xs)
+ def wrapArray(xs: Array[Int]): WrappedArray[Int] = new WrappedArray.ofInt(xs)
+ def wrapArray(xs: Array[Double]): WrappedArray[Double] = new WrappedArray.ofDouble(xs)
+ def wrapArray(xs: Array[Long]): WrappedArray[Long] = new WrappedArray.ofLong(xs)
+ def wrapArray(xs: Array[Float]): WrappedArray[Float] = new WrappedArray.ofFloat(xs)
+ def wrapArray(xs: Array[Char]): WrappedArray[Char] = new WrappedArray.ofChar(xs)
+ def wrapArray(xs: Array[Byte]): WrappedArray[Byte] = new WrappedArray.ofByte(xs)
+ def wrapArray(xs: Array[Short]): WrappedArray[Short] = new WrappedArray.ofShort(xs)
+ def wrapArray(xs: Array[Boolean]): WrappedArray[Boolean] = new WrappedArray.ofBoolean(xs)
+ def wrapArray(xs: Array[Unit]): WrappedArray[Unit] = new WrappedArray.ofUnit(xs)
+
+
}
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 3ab86869d1..6cb073b173 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -221,29 +221,29 @@ object Predef extends LowPriorityImplicits {
implicit def any2stringadd(x: Any) = new runtime.StringAdd(x)
implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = (xs: AnyRef) match { // !!! drop the AnyRef and get unreachable code errors!
- case x: Array[AnyRef] => arrayOps[AnyRef](x).asInstanceOf[ArrayOps[T]]
- case x: Array[Int] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Double] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Long] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Float] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Char] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Byte] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Short] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Boolean] => arrayOps(x).asInstanceOf[ArrayOps[T]]
- case x: Array[Unit] => arrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[AnyRef] => refArrayOps[AnyRef](x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Int] => intArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Double] => doubleArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Long] => longArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Float] => floatArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Char] => charArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Byte] => byteArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Short] => shortArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Boolean] => booleanArrayOps(x).asInstanceOf[ArrayOps[T]]
+ case x: Array[Unit] => unitArrayOps(x).asInstanceOf[ArrayOps[T]]
case null => null
}
- implicit def arrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps.ofRef[T](xs)
- implicit def arrayOps(xs: Array[Int]): ArrayOps[Int] = new ArrayOps.ofInt(xs)
- implicit def arrayOps(xs: Array[Double]): ArrayOps[Double] = new ArrayOps.ofDouble(xs)
- implicit def arrayOps(xs: Array[Long]): ArrayOps[Long] = new ArrayOps.ofLong(xs)
- implicit def arrayOps(xs: Array[Float]): ArrayOps[Float] = new ArrayOps.ofFloat(xs)
- implicit def arrayOps(xs: Array[Char]): ArrayOps[Char] = new ArrayOps.ofChar(xs)
- implicit def arrayOps(xs: Array[Byte]): ArrayOps[Byte] = new ArrayOps.ofByte(xs)
- implicit def arrayOps(xs: Array[Short]): ArrayOps[Short] = new ArrayOps.ofShort(xs)
- implicit def arrayOps(xs: Array[Boolean]): ArrayOps[Boolean] = new ArrayOps.ofBoolean(xs)
- implicit def arrayOps(xs: Array[Unit]): ArrayOps[Unit] = new ArrayOps.ofUnit(xs)
+ implicit def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps.ofRef[T](xs)
+ implicit def intArrayOps(xs: Array[Int]): ArrayOps[Int] = new ArrayOps.ofInt(xs)
+ implicit def doubleArrayOps(xs: Array[Double]): ArrayOps[Double] = new ArrayOps.ofDouble(xs)
+ implicit def longArrayOps(xs: Array[Long]): ArrayOps[Long] = new ArrayOps.ofLong(xs)
+ implicit def floatArrayOps(xs: Array[Float]): ArrayOps[Float] = new ArrayOps.ofFloat(xs)
+ implicit def charArrayOps(xs: Array[Char]): ArrayOps[Char] = new ArrayOps.ofChar(xs)
+ implicit def byteArrayOps(xs: Array[Byte]): ArrayOps[Byte] = new ArrayOps.ofByte(xs)
+ implicit def shortArrayOps(xs: Array[Short]): ArrayOps[Short] = new ArrayOps.ofShort(xs)
+ implicit def booleanArrayOps(xs: Array[Boolean]): ArrayOps[Boolean] = new ArrayOps.ofBoolean(xs)
+ implicit def unitArrayOps(xs: Array[Unit]): ArrayOps[Unit] = new ArrayOps.ofUnit(xs)
implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc)
diff --git a/src/library/scala/Range.scala b/src/library/scala/Range.scala
index e31c41de6b..5a27fa21de 100644
--- a/src/library/scala/Range.scala
+++ b/src/library/scala/Range.scala
@@ -12,7 +12,7 @@ package scala
import annotation.experimental
import collection.immutable.Vector
-import collection.generic.VectorView
+import collection.VectorView
import util.control.Exception.catching
import util.Hashable
diff --git a/src/library/scala/Unhashable.scala b/src/library/scala/Unhashable.scala
deleted file mode 100644
index 33f8e378dc..0000000000
--- a/src/library/scala/Unhashable.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-/** <p>
- * A marker trait for data structures that cannot be hashed, for instance
- * because they are mutable and at the same time support structural
- * equality, so hashing them would lead to unpredictable results.
- * </p>
- * <p>
- * Such data structures have <code>hashCode</code> throw an <a href=""
- * target="contentFrame" class="java/lang/UnsupportedOperationException">
- * <code>java.lang.UnsupportedOperationException</code></a>. They retain
- * the original object hashcode with <code>identityHashCode</code>.
- * </p>
- *
- * @author Martin Odersky
- * @version 1.0
- * @since 2.8
- */
-trait Unhashable extends Object {
-
- /** The hashCode method always yields an error, since it is not
- * safe to use sets as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode: Int =
- throw new UnsupportedOperationException("unsuitable as hash key")
-
- /** The identity hash code is the original hash code inherited from Object.
- */
- def identityHashCode: Int =
- super/*[Object]*/.hashCode // !!! super[Object] does not work here
-}
diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala
index b7a77c63ce..0a3eefde9d 100644
--- a/src/library/scala/collection/BitSet.scala
+++ b/src/library/scala/collection/BitSet.scala
@@ -16,7 +16,7 @@ import generic._
/** common base class for mutable and immutable bit sets
*/
trait BitSet extends Set[Int]
- with BitSetTemplate[BitSet] {
+ with BitSetLike[BitSet] {
override def empty: BitSet = BitSet.empty
}
diff --git a/src/library/scala/collection/generic/BitSetTemplate.scala b/src/library/scala/collection/BitSetLike.scala
index 670109a874..bc6fddbfea 100644
--- a/src/library/scala/collection/generic/BitSetTemplate.scala
+++ b/src/library/scala/collection/BitSetLike.scala
@@ -9,15 +9,14 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
-import BitSetTemplate._
+import BitSetLike._
import generic._
/** common base class for mutable and immutable bit sets
*/
-trait BitSetTemplate[+This <: BitSetTemplate[This] with Set[Int]] extends SetTemplate[Int, This] { self =>
+trait BitSetLike[+This <: BitSetLike[This] with Set[Int]] extends SetLike[Int, This] { self =>
def empty: This
@@ -130,7 +129,7 @@ trait BitSetTemplate[+This <: BitSetTemplate[This] with Set[Int]] extends SetTem
}
}
-object BitSetTemplate {
+object BitSetLike {
private[collection] val LogWL = 6
private val WordLength = 64
diff --git a/src/library/scala/collection/Iterable.scala b/src/library/scala/collection/Iterable.scala
index 70a74347be..9998e626ee 100644
--- a/src/library/scala/collection/Iterable.scala
+++ b/src/library/scala/collection/Iterable.scala
@@ -11,9 +11,9 @@
package scala.collection
-import scala.util.control.Breaks._
-// import immutable.Stream
import generic._
+import scala.util.control.Breaks._
+import mutable.Builder
/** <p>
* A template trait for iterable collections.
@@ -42,11 +42,11 @@ import generic._
* @version 2.8
*/
trait Iterable[+A] extends Traversable[A]
- with TraversableClass[A, Iterable]
- with IterableTemplate[A, Iterable[A]] {
- override def companion: Companion[Iterable] = Iterable
+ with GenericTraversableTemplate[A, Iterable]
+ with IterableLike[A, Iterable[A]] {
+ override def companion: GenericCompanion[Iterable] = Iterable
- /* The following methods are inherited from trait IterableTemplate
+ /* The following methods are inherited from trait IterableLike
*
override def iterator: Iterator[A]
override def takeRight(n: Int): Iterable[A]
diff --git a/src/library/scala/collection/IterableProxy.scala b/src/library/scala/collection/IterableProxy.scala
index e3d216ff8c..8d4289b467 100644
--- a/src/library/scala/collection/IterableProxy.scala
+++ b/src/library/scala/collection/IterableProxy.scala
@@ -21,4 +21,4 @@ import generic._
* @author Martin Odersky
* @version 2.8
*/
-trait IterableProxy[+A] extends Iterable[A] with IterableProxyTemplate[A, Iterable[A]]
+trait IterableProxy[+A] extends Iterable[A] with IterableProxyLike[A, Iterable[A]]
diff --git a/src/library/scala/collection/generic/IterableProxyTemplate.scala b/src/library/scala/collection/IterableProxyLike.scala
index 3d20be52fd..79ed050a8a 100644
--- a/src/library/scala/collection/generic/IterableProxyTemplate.scala
+++ b/src/library/scala/collection/IterableProxyLike.scala
@@ -9,12 +9,12 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
-import collection.mutable.Buffer
+import generic._
+import mutable.Buffer
-// Methods could be printed by cat IterableTemplate.scala | egrep '^ (override )?def'
+// Methods could be printed by cat IterableLike.scala | egrep '^ (override )?def'
/** This trait implements a proxy for iterable objects. It forwards
@@ -23,9 +23,9 @@ import collection.mutable.Buffer
* @author Martin Odersky
* @version 2.8
*/
-trait IterableProxyTemplate[+A, +This <: IterableTemplate[A, This] with Iterable[A]]
- extends IterableTemplate[A, This]
- with TraversableProxyTemplate[A, This]
+trait IterableProxyLike[+A, +This <: IterableLike[A, This] with Iterable[A]]
+ extends IterableLike[A, This]
+ with TraversableProxyLike[A, This]
{
override def iterator: Iterator[A] = self.iterator
override def foreach[U](f: A => U): Unit = self.foreach(f)
diff --git a/src/library/scala/collection/generic/IterableView.scala b/src/library/scala/collection/IterableView.scala
index 387cc78abb..ade1f294ca 100644
--- a/src/library/scala/collection/generic/IterableView.scala
+++ b/src/library/scala/collection/IterableView.scala
@@ -9,9 +9,9 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
import TraversableView.NoBuilder
/** A base class for views of Iterables.
@@ -19,7 +19,7 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait IterableView[+A, +Coll] extends IterableViewTemplate[A, Coll, IterableView[A, Coll]]
+trait IterableView[+A, +Coll] extends IterableViewLike[A, Coll, IterableView[A, Coll]]
object IterableView {
type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
diff --git a/src/library/scala/collection/generic/IterableViewTemplate.scala b/src/library/scala/collection/IterableViewLike.scala
index 2de03c1702..f76f55d1a6 100644
--- a/src/library/scala/collection/generic/IterableViewTemplate.scala
+++ b/src/library/scala/collection/IterableViewLike.scala
@@ -9,9 +9,9 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
import TraversableView.NoBuilder
/** A base class for views of Iterables.
@@ -19,10 +19,10 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait IterableViewTemplate[+A,
- +Coll,
- +This <: IterableView[A, Coll] with IterableViewTemplate[A, Coll, This]]
-extends Iterable[A] with IterableTemplate[A, This] with TraversableView[A, Coll] with TraversableViewTemplate[A, Coll, This]
+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]
{ self =>
trait Transformed[+B] extends IterableView[B, Coll] with super.Transformed[B]
@@ -58,7 +58,7 @@ extends Iterable[A] with IterableTemplate[A, This] with TraversableView[A, Coll]
trait Zipped[B] extends Transformed[(A, B)] {
protected[this] val other: Iterable[B]
override def iterator: Iterator[(A, B)] = self.iterator zip other.iterator
- override def stringPrefix = super.stringPrefix+"Z"
+ override def stringPrefix = self.stringPrefix+"Z"
}
trait ZippedAll[A1 >: A, B] extends Transformed[(A1, B)] {
@@ -101,4 +101,6 @@ extends Iterable[A] with IterableTemplate[A, This] with TraversableView[A, Coll]
protected override def newSliced(_from: Int, _until: Int): Transformed[A] = new Sliced { val from = _from; val until = _until }
protected override def newDroppedWhile(p: A => Boolean): Transformed[A] = new DroppedWhile { val pred = p }
protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new TakenWhile { val pred = p }
+
+ override def stringPrefix = "IterableView"
}
diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala
index d578e38fe6..a3c5574a5b 100644
--- a/src/library/scala/collection/JavaConversions.scala
+++ b/src/library/scala/collection/JavaConversions.scala
@@ -391,7 +391,7 @@ object JavaConversions {
}
- case class JSetWrapper[A](underlying : ju.Set[A]) extends mutable.Set[A] with generic.MutableSetTemplate[A, JSetWrapper[A]] {
+ case class JSetWrapper[A](underlying : ju.Set[A]) extends mutable.Set[A] with mutable.SetLike[A, JSetWrapper[A]] {
override def size = underlying.size
def iterator = underlying.iterator
@@ -461,7 +461,7 @@ object JavaConversions {
}
}
- case class JMapWrapper[A, B](underlying : ju.Map[A, B]) extends mutable.Map[A, B] with generic.MutableMapTemplate[A, B, JMapWrapper[A, B]] {
+ case class JMapWrapper[A, B](underlying : ju.Map[A, B]) extends mutable.Map[A, B] with mutable.MapLike[A, B, JMapWrapper[A, B]] {
override def size = underlying.size
def get(k : A) = {
diff --git a/src/library/scala/collection/LinearSequence.scala b/src/library/scala/collection/LinearSequence.scala
index bfe4879eb1..aa3910887d 100644
--- a/src/library/scala/collection/LinearSequence.scala
+++ b/src/library/scala/collection/LinearSequence.scala
@@ -12,6 +12,7 @@
package scala.collection
import generic._
+import mutable.Builder
/** <p>
* Class <code>Linear[A]</code> represents linear sequences of elements.
@@ -27,9 +28,9 @@ import generic._
* @version 1.0, 16/07/2003
*/
trait LinearSequence[+A] extends Sequence[A]
- with TraversableClass[A, LinearSequence]
- with LinearSequenceTemplate[A, LinearSequence[A]] {
- override def companion: Companion[LinearSequence] = LinearSequence
+ with GenericTraversableTemplate[A, LinearSequence]
+ with LinearSequenceLike[A, LinearSequence[A]] {
+ override def companion: GenericCompanion[LinearSequence] = LinearSequence
}
object LinearSequence extends SequenceFactory[LinearSequence] {
diff --git a/src/library/scala/collection/LinearSequenceLike.scala b/src/library/scala/collection/LinearSequenceLike.scala
index a48a4780a4..bbb8d2100e 100644
--- a/src/library/scala/collection/LinearSequenceLike.scala
+++ b/src/library/scala/collection/LinearSequenceLike.scala
@@ -13,8 +13,6 @@ package scala.collection
import generic._
import mutable.ListBuffer
-// import immutable.{List, Nil, ::}
-import generic._
import scala.util.control.Breaks._
/** Class <code>Linear[A]</code> represents linear sequences of elements.
diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala
index c7d656052e..309c529f6f 100644
--- a/src/library/scala/collection/Map.scala
+++ b/src/library/scala/collection/Map.scala
@@ -36,9 +36,9 @@ import generic._
* you might consider inheriting from <code>DefaultMap</code> instead.
*
* @note Of you additions and mutations return the same kind of map as the map
- * you are defining, you should inherit from <code>MapTemplate</code> as well.
+ * you are defining, you should inherit from <code>MapLike</code> as well.
*/
-trait Map[A, +B] extends Iterable[(A, B)] with MapTemplate[A, B, Map[A, B]] {
+trait Map[A, +B] extends Iterable[(A, B)] with MapLike[A, B, Map[A, B]] {
def empty: Map[A, B] = Map.empty
}
diff --git a/src/library/scala/collection/generic/MapTemplate.scala b/src/library/scala/collection/MapLike.scala
index cf0fdcbc3d..82a70e0979 100644
--- a/src/library/scala/collection/generic/MapTemplate.scala
+++ b/src/library/scala/collection/MapLike.scala
@@ -8,9 +8,10 @@
// $Id$
-package scala.collection.generic
+package scala.collection
-import scala.collection._
+import generic._
+import mutable.{Builder, MapBuilder}
import PartialFunction._
/** <p>
@@ -39,9 +40,9 @@ import PartialFunction._
* @author Martin Odersky
* @version 2.8
*/
-trait MapTemplate[A, +B, +This <: MapTemplate[A, B, This] with Map[A, B]]
+trait MapLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]]
extends PartialFunction[A, B]
- with IterableTemplate[(A, B), This]
+ with IterableLike[(A, B), This]
with Subtractable[A, This] {
self =>
@@ -49,7 +50,7 @@ self =>
def empty: This
/** A common implementation of `newBuilder` for all maps in terms of `empty`.
- * Overridden for mutable maps in `MutableMapTemplate`.
+ * Overridden for mutable maps in `mutable.MapLike`.
*/
override protected[this] def newBuilder: Builder[(A, B), This] = new MapBuilder[A, B, This](empty)
@@ -262,7 +263,7 @@ self =>
/** Need to override string, so that it's not the Function1's string that gets mixed in.
*/
- override def toString = super[IterableTemplate].toString
+ override def toString = super[IterableLike].toString
override def hashCode() = this map (_.hashCode) sum
diff --git a/src/library/scala/collection/MapProxy.scala b/src/library/scala/collection/MapProxy.scala
index ecf3d9d13c..e500646430 100644
--- a/src/library/scala/collection/MapProxy.scala
+++ b/src/library/scala/collection/MapProxy.scala
@@ -11,8 +11,6 @@
package scala.collection
-import generic.MapProxyTemplate
-
/** This is a simple wrapper class for <a href="Map.html"
* target="contentFrame"><code>scala.collection.Map</code></a>.
* It is most useful for assembling customized map abstractions
@@ -21,4 +19,4 @@ import generic.MapProxyTemplate
* @author Matthias Zenger
* @version 1.0, 21/07/2003
*/
-trait MapProxy[A, +B] extends Map[A, B] with MapProxyTemplate[A, B, Map[A, B]]
+trait MapProxy[A, +B] extends Map[A, B] with MapProxyLike[A, B, Map[A, B]]
diff --git a/src/library/scala/collection/generic/MapProxyTemplate.scala b/src/library/scala/collection/MapProxyLike.scala
index ff32c38dc4..7a9b98bd97 100644
--- a/src/library/scala/collection/generic/MapProxyTemplate.scala
+++ b/src/library/scala/collection/MapProxyLike.scala
@@ -6,10 +6,11 @@
** |/ **
\* */
-package scala.collection.generic
-import scala.collection._
+package scala.collection
-// Methods could be printed by cat MapTemplate.scala | egrep '^ (override )?def'
+import generic._
+
+// Methods could be printed by cat MapLike.scala | egrep '^ (override )?def'
/** This trait implements a proxy for iterable objects. It forwards
* all calls to a different iterable object
@@ -17,9 +18,9 @@ import scala.collection._
* @author Martin Odersky
* @version 2.8
*/
-trait MapProxyTemplate[A, +B, +This <: MapTemplate[A, B, This] with Map[A, B]]
- extends MapTemplate[A, B, This]
- with IterableProxyTemplate[(A, B), This]
+trait MapProxyLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]]
+ extends MapLike[A, B, This]
+ with IterableProxyLike[(A, B), This]
{
// def empty: This
// def + [B1 >: B] (kv: (A, B1)): Map[A, B1]
diff --git a/src/library/scala/collection/Sequence.scala b/src/library/scala/collection/Sequence.scala
index 14e09efe0d..b9439c909b 100644
--- a/src/library/scala/collection/Sequence.scala
+++ b/src/library/scala/collection/Sequence.scala
@@ -11,7 +11,8 @@
package scala.collection
-import scala.collection.generic._
+import generic._
+import mutable.Builder
/** <p>
* Class <code>Sequence[A]</code> represents sequences of elements
@@ -31,9 +32,9 @@ import scala.collection.generic._
*/
trait Sequence[+A] extends PartialFunction[Int, A]
with Iterable[A]
- with TraversableClass[A, Sequence]
- with SequenceTemplate[A, Sequence[A]] {
- override def companion: Companion[Sequence] = Sequence
+ with GenericTraversableTemplate[A, Sequence]
+ with SequenceLike[A, Sequence[A]] {
+ override def companion: GenericCompanion[Sequence] = Sequence
}
/** Factory object for <code>Sequence</code> trait.
diff --git a/src/library/scala/collection/SequenceLike.scala b/src/library/scala/collection/SequenceLike.scala
index 547864abc5..5f3979bde1 100644
--- a/src/library/scala/collection/SequenceLike.scala
+++ b/src/library/scala/collection/SequenceLike.scala
@@ -16,6 +16,84 @@ import mutable.{ListBuffer, HashMap, GenericArray}
// import immutable.{List, Nil, ::}
import generic._
+/** Contains a KMP implementation, based on the undoubtedly reliable wikipedia entry.
+ *
+ * @author paulp
+ */
+object SequenceLike {
+
+ private def KMP[B](S: Seq[B], W: Seq[B]): Option[Int] = {
+ // trivial cases
+ if (W.isEmpty) return Some(0)
+ else if (W drop 1 isEmpty) return (S indexOf W(0)) match {
+ case -1 => None
+ case x => Some(x)
+ }
+
+ val T: Array[Int] = {
+ val arr = new Array[Int](W.length)
+ var pos = 2
+ var cnd = 0
+ arr(0) = -1
+ arr(1) = 0
+ while (pos < W.length) {
+ if (W(pos - 1) == W(cnd)) {
+ arr(pos) = cnd + 1
+ pos += 1
+ cnd += 1
+ }
+ else if (cnd > 0) {
+ cnd = arr(cnd)
+ }
+ else {
+ arr(pos) = 0
+ pos += 1
+ }
+ }
+ arr
+ }
+
+ var m, i = 0
+ def mi = m + i
+
+ while (mi < S.length) {
+ if (W(i) == S(mi)) {
+ i += 1
+ if (i == W.length)
+ return Some(m)
+ }
+ else {
+ m = mi - T(i)
+ if (i > 0)
+ i = T(i)
+ }
+ }
+ None
+ }
+
+ def indexOf[B](
+ source: Seq[B], sourceOffset: Int, sourceCount: Int,
+ target: Seq[B], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int =
+ KMP(source.slice(sourceOffset, sourceCount) drop fromIndex, target.slice(targetOffset, targetCount)) match {
+ case None => -1
+ case Some(x) => x + fromIndex
+ }
+
+ def lastIndexOf[B](
+ source: Seq[B], sourceOffset: Int, sourceCount: Int,
+ target: Seq[B], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int = {
+ val src = (source.slice(sourceOffset, sourceCount) take fromIndex).reverse
+ val tgt = target.slice(targetOffset, targetCount).reverse
+
+ KMP(src, tgt) match {
+ case None => -1
+ case Some(x) => (src.length - tgt.length - x) + sourceOffset
+ }
+ }
+}
+
/** Class <code>Sequence[A]</code> represents sequences of elements
* of type <code>A</code>.
* It adds the following methods to class Iterable:
@@ -262,7 +340,7 @@ trait SequenceLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
def indexOfSeq[B >: A](that: Sequence[B], fromIndex: Int): Int =
if (this.hasDefiniteSize && that.hasDefiniteSize)
- KMP.indexOf(thisCollection, 0, length, that, 0, that.length, fromIndex)
+ SequenceLike.indexOf(thisCollection, 0, length, that, 0, that.length, fromIndex)
else {
var i = fromIndex
var s: Sequence[A] = thisCollection drop i
@@ -285,7 +363,7 @@ trait SequenceLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
// since there's no way to find the last index in an infinite sequence,
// we just document it may not terminate and assume it will.
def lastIndexOfSeq[B >: A](that: Sequence[B], fromIndex: Int): Int =
- KMP.lastIndexOf(thisCollection, 0, length, that, 0, that.length, fromIndex)
+ SequenceLike.lastIndexOf(thisCollection, 0, length, that, 0, that.length, fromIndex)
/** Tests if the given value <code>elem</code> is a member of this
* sequence.
@@ -370,11 +448,7 @@ trait SequenceLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
}
private def occCounts[B](seq: Sequence[B]): mutable.Map[B, Int] = {
- val occ =
- if (seq.isEmpty || seq.head.isInstanceOf[Unhashable])
- new mutable.ListMap[B, Int] { override def default(k: B) = 0 }
- else
- new mutable.HashMap[B, Int] { override def default(k: B) = 0 }
+ val occ = new mutable.HashMap[B, Int] { override def default(k: B) = 0 }
for (y <- seq) occ(y) += 1
occ
}
diff --git a/src/library/scala/collection/SequenceProxy.scala b/src/library/scala/collection/SequenceProxy.scala
index 9284613c72..911139c152 100644
--- a/src/library/scala/collection/SequenceProxy.scala
+++ b/src/library/scala/collection/SequenceProxy.scala
@@ -11,13 +11,10 @@
package scala.collection
-import generic._
-
-
/** This trait implements a proxy for sequence objects. It forwards
* all calls to a different sequence object.
*
* @author Martin Odersky
* @version 2.8
*/
-trait SequenceProxy[+A] extends Sequence[A] with SequenceProxyTemplate[A, Sequence[A]]
+trait SequenceProxy[+A] extends Sequence[A] with SequenceProxyLike[A, Sequence[A]]
diff --git a/src/library/scala/collection/generic/SequenceProxyTemplate.scala b/src/library/scala/collection/SequenceProxyLike.scala
index 022bde02d1..06d1701245 100644
--- a/src/library/scala/collection/generic/SequenceProxyTemplate.scala
+++ b/src/library/scala/collection/SequenceProxyLike.scala
@@ -9,12 +9,11 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
-import collection.mutable.Buffer
+import generic._
-// Methods could be printed by cat SequenceTemplate.scala | egrep '^ (override )?def'
+// Methods could be printed by cat SequenceLike.scala | egrep '^ (override )?def'
/** This trait implements a proxy for sequences. It forwards
@@ -23,7 +22,7 @@ import collection.mutable.Buffer
* @author Martin Odersky
* @version 2.8
*/
-trait SequenceProxyTemplate[+A, +This <: SequenceTemplate[A, This] with Sequence[A]] extends SequenceTemplate[A, This] with IterableProxyTemplate[A, This] {
+trait SequenceProxyLike[+A, +This <: SequenceLike[A, This] with Sequence[A]] extends SequenceLike[A, This] with IterableProxyLike[A, This] {
override def length: Int = self.length
override def apply(idx: Int): A = self.apply(idx)
override def lengthCompare(len: Int): Int = self.lengthCompare(len)
diff --git a/src/library/scala/collection/generic/SequenceView.scala b/src/library/scala/collection/SequenceView.scala
index b665ffdc1f..3a03493932 100644
--- a/src/library/scala/collection/generic/SequenceView.scala
+++ b/src/library/scala/collection/SequenceView.scala
@@ -9,9 +9,9 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
import TraversableView.NoBuilder
/** A non-strict projection of an iterable.
@@ -19,7 +19,7 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait SequenceView[+A, +Coll] extends SequenceViewTemplate[A, Coll, SequenceView[A, Coll]]
+trait SequenceView[+A, +Coll] extends SequenceViewLike[A, Coll, SequenceView[A, Coll]]
object SequenceView {
type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
diff --git a/src/library/scala/collection/generic/SequenceViewTemplate.scala b/src/library/scala/collection/SequenceViewLike.scala
index 547e929aab..c57985e044 100644
--- a/src/library/scala/collection/generic/SequenceViewTemplate.scala
+++ b/src/library/scala/collection/SequenceViewLike.scala
@@ -9,9 +9,9 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
import Sequence.fill
import TraversableView.NoBuilder
@@ -20,10 +20,10 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait SequenceViewTemplate[+A,
+trait SequenceViewLike[+A,
+Coll,
- +This <: SequenceView[A, Coll] with SequenceViewTemplate[A, Coll, This]]
- extends Sequence[A] with SequenceTemplate[A, This] with IterableView[A, Coll] with IterableViewTemplate[A, Coll, This]
+ +This <: SequenceView[A, Coll] with SequenceViewLike[A, Coll, This]]
+ extends Sequence[A] with SequenceLike[A, This] with IterableView[A, Coll] with IterableViewLike[A, Coll, This]
{ self =>
trait Transformed[+B] extends SequenceView[B, Coll] with super.Transformed[B] {
@@ -106,7 +106,7 @@ trait SequenceViewTemplate[+A,
override def iterator: Iterator[A] = self.reverseIterator
override def length: Int = self.length
override def apply(idx: Int): A = self.apply(length - 1 - idx)
- override def stringPrefix = super.stringPrefix+"R"
+ override def stringPrefix = self.stringPrefix+"R"
}
trait Patched[B >: A] extends Transformed[B] {
@@ -120,7 +120,7 @@ trait SequenceViewTemplate[+A,
if (idx < from) self.apply(idx)
else if (idx < from + plen) patch.apply(idx - from)
else self.apply(idx - plen + replaced)
- override def stringPrefix = super.stringPrefix+"P"
+ override def stringPrefix = self.stringPrefix+"P"
}
/** Boilerplate method, to override in each subclass
@@ -149,6 +149,8 @@ trait SequenceViewTemplate[+A,
override def padTo[B >: A, That](len: Int, elem: B)(implicit bf: BuilderFactory[B, That, This]): That =
patch(length, fill(len - length)(elem), 0)
+
+ override def stringPrefix = "SequenceView"
}
diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala
index f7d1208dff..91df1e076b 100644
--- a/src/library/scala/collection/Set.scala
+++ b/src/library/scala/collection/Set.scala
@@ -22,9 +22,9 @@ import generic._
*/
trait Set[A] extends (A => Boolean)
with Iterable[A]
- with SetClass[A, Set]
- with SetTemplate[A, Set[A]] {
- override def companion: Companion[Set] = Set
+ with GenericSetTemplate[A, Set]
+ with SetLike[A, Set[A]] {
+ override def companion: GenericCompanion[Set] = Set
}
/** Factory object for <code>Set</code> class.
diff --git a/src/library/scala/collection/generic/SetTemplate.scala b/src/library/scala/collection/SetLike.scala
index 88061cb4f5..0752f4185f 100644
--- a/src/library/scala/collection/generic/SetTemplate.scala
+++ b/src/library/scala/collection/SetLike.scala
@@ -8,8 +8,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+
+import generic._
+import mutable.{Builder, AddingBuilder}
import PartialFunction._
/** <p>
@@ -37,7 +39,7 @@ import PartialFunction._
* @author Martin Odersky
* @version 2.8
*/
-trait SetTemplate[A, +This <: SetTemplate[A, This] with Set[A]] extends IterableTemplate[A, This] with Addable[A, This] with Subtractable[A, This] {
+trait SetLike[A, +This <: SetLike[A, This] with Set[A]] extends IterableLike[A, This] with Addable[A, This] with Subtractable[A, This] {
self =>
/* The empty set of the dame type as this set */
@@ -45,8 +47,8 @@ self =>
/** A common implementation of <code>newBuilder</code> for all sets in terms
* of <code>empty</code>. Overridden for mutable sets in
- * <a href="MutableSetTemplate.html" target="ContentFrame">
- * <code>MutableSetTemplate</code></a>.
+ * <a href="mutable/SetLike.html" target="ContentFrame">
+ * <code>mutable.SetLike</code></a>.
*/
override protected[this] def newBuilder: Builder[A, This] = new AddingBuilder[A, This](empty)
@@ -160,7 +162,7 @@ self =>
/** Need to override string, so that it's not the Function1's string that gets mixed in.
*/
- override def toString = super[IterableTemplate].toString
+ override def toString = super[IterableLike].toString
override def hashCode() = this map (_.hashCode) sum
diff --git a/src/library/scala/collection/SetProxy.scala b/src/library/scala/collection/SetProxy.scala
index e23a1c0286..dfa8fe0926 100644
--- a/src/library/scala/collection/SetProxy.scala
+++ b/src/library/scala/collection/SetProxy.scala
@@ -11,8 +11,6 @@
package scala.collection
-import generic.SetProxyTemplate
-
/** This is a simple wrapper class for <a href="Set.html"
* target="contentFrame"><code>scala.collection.Set</code></a>.
* It is most useful for assembling customized set abstractions
@@ -23,4 +21,4 @@ import generic.SetProxyTemplate
* @version 2.0, 01/01/2007
*/
-trait SetProxy[A] extends Set[A] with SetProxyTemplate[A, Set[A]]
+trait SetProxy[A] extends Set[A] with SetProxyLike[A, Set[A]]
diff --git a/src/library/scala/collection/generic/SetProxyTemplate.scala b/src/library/scala/collection/SetProxyLike.scala
index 057025e5c5..b4bb67e876 100644
--- a/src/library/scala/collection/generic/SetProxyTemplate.scala
+++ b/src/library/scala/collection/SetProxyLike.scala
@@ -7,10 +7,11 @@
\* */
-package scala.collection.generic
-import scala.collection._
+package scala.collection
-// Methods could be printed by cat SetTemplate.scala | egrep '^ (override )?def'
+import generic._
+
+// Methods could be printed by cat SetLike.scala | egrep '^ (override )?def'
/** This trait implements a proxy for sets. It forwards
* all calls to a different set.
@@ -18,7 +19,7 @@ import scala.collection._
* @author Martin Odersky
* @version 2.8
*/
-trait SetProxyTemplate[A, +This <: SetTemplate[A, This] with Set[A]] extends SetTemplate[A, This] with IterableProxyTemplate[A, This]
+trait SetProxyLike[A, +This <: SetLike[A, This] with Set[A]] extends SetLike[A, This] with IterableProxyLike[A, This]
{
// def empty: This
// def + (elem: A): This
diff --git a/src/library/scala/collection/SortedMap.scala b/src/library/scala/collection/SortedMap.scala
index b02c9f2866..5cfd450727 100644
--- a/src/library/scala/collection/SortedMap.scala
+++ b/src/library/scala/collection/SortedMap.scala
@@ -10,6 +10,7 @@
package scala.collection
import generic._
+import mutable.Builder
/** A map whose keys are sorted.
*
@@ -17,7 +18,7 @@ import generic._
* @author Martin Odersky
* @version 2.8
*/
-trait SortedMap[A, +B] extends Map[A, B] with SortedMapTemplate[A, B, SortedMap[A, B]] {
+trait SortedMap[A, +B] extends Map[A, B] with SortedMapLike[A, B, SortedMap[A, B]] {
/** Needs to be overridden in subclasses. */
override def empty = SortedMap.empty[A, B]
diff --git a/src/library/scala/collection/generic/SortedMapTemplate.scala b/src/library/scala/collection/SortedMapLike.scala
index b6bdd15deb..083bb46257 100644
--- a/src/library/scala/collection/generic/SortedMapTemplate.scala
+++ b/src/library/scala/collection/SortedMapLike.scala
@@ -9,18 +9,19 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+
+import generic._
/** A template for maps whose keys are sorted.
* To create a concrete sorted map, you need to implement the rangeImpl method,
- * in addition to those of `MapTemplate`.
+ * in addition to those of `MapLike`.
*
* @author Sean McDirmid
* @author Martin Odersky
* @version 2.8
*/
-trait SortedMapTemplate[A, +B, +This <: SortedMapTemplate[A, B, This] with SortedMap[A, B]] extends Sorted[A, This] with MapTemplate[A, B, This] {
+trait SortedMapLike[A, +B, +This <: SortedMapLike[A, B, This] with SortedMap[A, B]] extends Sorted[A, This] with MapLike[A, B, This] {
self =>
def firstKey : A = head._1
diff --git a/src/library/scala/collection/SortedSet.scala b/src/library/scala/collection/SortedSet.scala
index cf2781ab39..c6eb6ea570 100644
--- a/src/library/scala/collection/SortedSet.scala
+++ b/src/library/scala/collection/SortedSet.scala
@@ -10,15 +10,13 @@
package scala.collection
-import generic._
-
/** A sorted set.
*
* @author Sean McDirmid
* @author Martin Odersky
* @version 2.8
*/
-trait SortedSet[A] extends Set[A] with SortedSetTemplate[A, SortedSet[A]] {
+trait SortedSet[A] extends Set[A] with SortedSetLike[A, SortedSet[A]] {
/** Needs to be overridden in subclasses. */
override def empty: SortedSet[A] = throw new UnsupportedOperationException("SortedMap.empty")
}
diff --git a/src/library/scala/collection/generic/SortedSetTemplate.scala b/src/library/scala/collection/SortedSetLike.scala
index ffc8f4c39d..3d595b8f29 100644
--- a/src/library/scala/collection/generic/SortedSetTemplate.scala
+++ b/src/library/scala/collection/SortedSetLike.scala
@@ -8,8 +8,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
/** A template for sets which are sorted.
*
@@ -17,7 +17,7 @@ import scala.collection._
* @author Martin Odersky
* @version 2.8
*/
-trait SortedSetTemplate[A, +This <: SortedSet[A] with SortedSetTemplate[A, This]] extends Sorted[A, This] with SetTemplate[A, This] {
+trait SortedSetLike[A, +This <: SortedSet[A] with SortedSetLike[A, This]] extends Sorted[A, This] with SetLike[A, This] {
self =>
override def keySet = repr
diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala
index 07d518af10..717d832d90 100644
--- a/src/library/scala/collection/Traversable.scala
+++ b/src/library/scala/collection/Traversable.scala
@@ -11,10 +11,9 @@
package scala.collection
-// import immutable.{List, Stream, Nil}
-import mutable.{Buffer, ArrayBuffer, ListBuffer}
-import scala.util.control.Breaks
import generic._
+import mutable.{Builder, Buffer, ArrayBuffer, ListBuffer}
+import scala.util.control.Breaks
/** <p>
* A template trait for traversable collections.
@@ -30,11 +29,11 @@ import generic._
* @author Martin Odersky
* @version 2.8
*/
-trait Traversable[+A] extends TraversableTemplate[A, Traversable[A]]
- with TraversableClass[A, Traversable] {
- def companion: Companion[Traversable] = Traversable
+trait Traversable[+A] extends TraversableLike[A, Traversable[A]]
+ with GenericTraversableTemplate[A, Traversable] {
+ def companion: GenericCompanion[Traversable] = Traversable
- /* The following methods are inherited from TraversableTemplate
+ /* The following methods are inherited from TraversableLike
*
override def isEmpty: Boolean
override def size: Int
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 482b5063a1..ddd637d62a 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -13,7 +13,7 @@ package scala.collection
import generic._
import scala.reflect.ClassManifest
-import mutable.{Buffer, ArrayBuffer, ListBuffer}
+import mutable.{Builder, Buffer, ArrayBuffer, ListBuffer}
import annotation.experimental
/** <p>
diff --git a/src/library/scala/collection/TraversableProxy.scala b/src/library/scala/collection/TraversableProxy.scala
index ceaf034d05..54e3ea705d 100644
--- a/src/library/scala/collection/TraversableProxy.scala
+++ b/src/library/scala/collection/TraversableProxy.scala
@@ -11,9 +11,7 @@
package scala.collection
-import generic._
-
-// Methods could be printed by cat TraversibeTemplate.scala | egrep '^ (override )?def'
+// Methods could be printed by cat TraversibeLike.scala | egrep '^ (override )?def'
/** This trait implements a proxy for traversable objects. It forwards
@@ -22,4 +20,4 @@ import generic._
* @author Martin Odersky
* @version 2.8
*/
-trait TraversableProxy[+A] extends Traversable[A] with TraversableProxyTemplate[A, Traversable[A]]
+trait TraversableProxy[+A] extends Traversable[A] with TraversableProxyLike[A, Traversable[A]]
diff --git a/src/library/scala/collection/generic/TraversableProxyTemplate.scala b/src/library/scala/collection/TraversableProxyLike.scala
index 183a74f1c1..e667e7cc7f 100644
--- a/src/library/scala/collection/generic/TraversableProxyTemplate.scala
+++ b/src/library/scala/collection/TraversableProxyLike.scala
@@ -9,12 +9,12 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
-import collection.mutable.Buffer
+import generic._
+import mutable.Buffer
-// Methods could be printed by cat TraversableTemplate.scala | egrep '^ (override )?def'
+// Methods could be printed by cat TraversableLike.scala | egrep '^ (override )?def'
/** This trait implements a proxy for traversable objects. It forwards
@@ -23,7 +23,7 @@ import collection.mutable.Buffer
* @author Martin Odersky
* @version 2.8
*/
-trait TraversableProxyTemplate[+A, +This <: TraversableTemplate[A, This] with Traversable[A]] extends TraversableTemplate[A, This] with Proxy {
+trait TraversableProxyLike[+A, +This <: TraversableLike[A, This] with Traversable[A]] extends TraversableLike[A, This] with Proxy {
def self: This
override def foreach[B](f: A => B): Unit = self.foreach(f)
@@ -85,11 +85,11 @@ trait TraversableProxyTemplate[+A, +This <: TraversableTemplate[A, This] with Tr
override def view(from: Int, until: Int): TraversableView[A, This] = self.view(from, until)
}
-private class TraversableProxyTemplateConfirmation[+A, +This <: TraversableTemplate[A, This] with Traversable[A]]
- extends TraversableProxyTemplate[A, Traversable[A]]
+private class TraversableProxyLikeConfirmation[+A, +This <: TraversableLike[A, This] with Traversable[A]]
+ extends TraversableProxyLike[A, Traversable[A]]
with interfaces.TraversableMethods[A, Traversable[A]]
{
def self: This = repr.asInstanceOf[This]
- protected[this] def newBuilder = collection.Traversable.newBuilder[A]
+ protected[this] def newBuilder = scala.collection.Traversable.newBuilder[A]
// : Builder[A, This]
}
diff --git a/src/library/scala/collection/generic/TraversableView.scala b/src/library/scala/collection/TraversableView.scala
index b5367f347a..e5d5400cf9 100644
--- a/src/library/scala/collection/generic/TraversableView.scala
+++ b/src/library/scala/collection/TraversableView.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
+import mutable.Builder
import TraversableView.NoBuilder
/** <p>
@@ -23,7 +24,7 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait TraversableView[+A, +Coll] extends TraversableViewTemplate[A, Coll, TraversableView[A, Coll]]
+trait TraversableView[+A, +Coll] extends TraversableViewLike[A, Coll, TraversableView[A, Coll]]
object TraversableView {
class NoBuilder[A] extends Builder[A, Nothing] {
diff --git a/src/library/scala/collection/generic/TraversableViewTemplate.scala b/src/library/scala/collection/TraversableViewLike.scala
index 347ad60221..b19c02ea35 100644
--- a/src/library/scala/collection/generic/TraversableViewTemplate.scala
+++ b/src/library/scala/collection/TraversableViewLike.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
+import mutable.Builder
import Math.MAX_INT
import TraversableView.NoBuilder
@@ -30,10 +31,10 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait TraversableViewTemplate[+A,
- +Coll,
- +This <: TraversableView[A, Coll] with TraversableViewTemplate[A, Coll, This]]
- extends Traversable[A] with TraversableTemplate[A, This] {
+trait TraversableViewLike[+A,
+ +Coll,
+ +This <: TraversableView[A, Coll] with TraversableViewLike[A, Coll, This]]
+ extends Traversable[A] with TraversableLike[A, This] {
self =>
override protected[this] def newBuilder: Builder[A, This] =
@@ -174,5 +175,5 @@ self =>
override def takeWhile(p: A => Boolean): This = newTakenWhile(p).asInstanceOf[This]
override def span(p: A => Boolean): (This, This) = (takeWhile(p), dropWhile(p))
override def splitAt(n: Int): (This, This) = (take(n), drop(n))
+ override def stringPrefix = "TraversableView"
}
-
diff --git a/src/library/scala/collection/Vector.scala b/src/library/scala/collection/Vector.scala
index 15cbd11638..a642caba33 100644
--- a/src/library/scala/collection/Vector.scala
+++ b/src/library/scala/collection/Vector.scala
@@ -12,7 +12,7 @@
package scala.collection
import generic._
-import mutable.ArrayBuffer
+import mutable.{Builder, ArrayBuffer}
/** <p>
* Sequences that support O(1) element access and O(1) length computation.
@@ -27,9 +27,9 @@ import mutable.ArrayBuffer
* @version 2.8
*/
trait Vector[+A] extends Sequence[A]
- with TraversableClass[A, Vector]
- with VectorTemplate[A, Vector[A]] {
- override def companion: Companion[Vector] = Vector
+ with GenericTraversableTemplate[A, Vector]
+ with VectorLike[A, Vector[A]] {
+ override def companion: GenericCompanion[Vector] = Vector
}
object Vector extends SequenceFactory[Vector] {
diff --git a/src/library/scala/collection/VectorLike.scala b/src/library/scala/collection/VectorLike.scala
index a1d04214a2..1e2548a12f 100644
--- a/src/library/scala/collection/VectorLike.scala
+++ b/src/library/scala/collection/VectorLike.scala
@@ -27,7 +27,7 @@ trait VectorLike[+A, +Repr] extends SequenceLike[A, Repr] { self =>
override protected[this] def thisCollection: Vector[A] = this.asInstanceOf[Vector[A]]
override protected[this] def toCollection(repr: Repr): Vector[A] = repr.asInstanceOf[Vector[A]]
- // Overridden methods from IterableTemplate
+ // Overridden methods from IterableLike
/** The iterator returned by the iterator method
*/
diff --git a/src/library/scala/collection/generic/VectorView.scala b/src/library/scala/collection/VectorView.scala
index 7eae0c121c..f13f764f77 100644
--- a/src/library/scala/collection/generic/VectorView.scala
+++ b/src/library/scala/collection/VectorView.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
import TraversableView.NoBuilder
+import generic._
/** A non-strict projection of an iterable.
*
@@ -20,7 +20,7 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait VectorView[+A, +Coll] extends VectorViewTemplate[A, Coll, VectorView[A, Coll]]
+trait VectorView[+A, +Coll] extends VectorViewLike[A, Coll, VectorView[A, Coll]]
object VectorView {
type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
diff --git a/src/library/scala/collection/generic/VectorViewTemplate.scala b/src/library/scala/collection/VectorViewLike.scala
index ee609be2cc..99ca5ab023 100644
--- a/src/library/scala/collection/generic/VectorViewTemplate.scala
+++ b/src/library/scala/collection/VectorViewLike.scala
@@ -6,12 +6,12 @@
** |/ **
\* */
-// $Id$
+// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+import generic._
import TraversableView.NoBuilder
/** A non-strict projection of an iterable.
@@ -20,10 +20,10 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait VectorViewTemplate[+A,
+trait VectorViewLike[+A,
+Coll,
- +This <: VectorView[A, Coll] with VectorViewTemplate[A, Coll, This]]
- extends Vector[A] with VectorTemplate[A, This] with SequenceView[A, Coll] with SequenceViewTemplate[A, Coll, This]
+ +This <: VectorView[A, Coll] with VectorViewLike[A, Coll, This]]
+ extends Vector[A] with VectorLike[A, This] with SequenceView[A, Coll] with SequenceViewLike[A, Coll, This]
{ self =>
trait Transformed[+B] extends VectorView[B, Coll] with super.Transformed[B]
@@ -69,7 +69,7 @@ trait VectorViewTemplate[+A,
protected[this] val other: Iterable[B]
def length = self.length min other.size
def apply(idx: Int): (A, B) = (self.apply(idx), other.iterator drop idx next)
- override def stringPrefix = super.stringPrefix+"Z"
+ override def stringPrefix = self.stringPrefix+"Z"
}
trait ZippedAll[A1 >: A, B] extends Transformed[(A1, B)] {
@@ -85,7 +85,7 @@ trait VectorViewTemplate[+A,
val z2 = if (idx < other.size) other drop idx head else thatElem
(z1, z2)
}
- override def stringPrefix = super.stringPrefix+"Z"
+ override def stringPrefix = self.stringPrefix+"Z"
}
/** Boilerplate method, to override in each subclass
@@ -110,4 +110,5 @@ trait VectorViewTemplate[+A,
val thisElem = _thisElem
val thatElem = _thatElem
}
+ override def stringPrefix = "VectorView"
}
diff --git a/src/library/scala/collection/generic/Addable.scala b/src/library/scala/collection/generic/Addable.scala
index 5cde44cef1..45b81e41fb 100644
--- a/src/library/scala/collection/generic/Addable.scala
+++ b/src/library/scala/collection/generic/Addable.scala
@@ -8,8 +8,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
/** This class represents collections that can be added to other
* collections using a '+' operator.
diff --git a/src/library/scala/collection/generic/BitSetFactory.scala b/src/library/scala/collection/generic/BitSetFactory.scala
index 8bd7b7883b..0c9319aae5 100644
--- a/src/library/scala/collection/generic/BitSetFactory.scala
+++ b/src/library/scala/collection/generic/BitSetFactory.scala
@@ -9,11 +9,13 @@
// $Id$
-package scala.collection.generic
+package scala.collection
+package generic
import scala.collection._
+import mutable.{Builder, AddingBuilder}
-trait BitSetFactory[Coll <: BitSet with BitSetTemplate[Coll]] {
+trait BitSetFactory[Coll <: BitSet with BitSetLike[Coll]] {
def newBuilder: Builder[Int, Coll] = new AddingBuilder[Int, Coll](empty)
def empty: Coll
def apply(elems: Int*): Coll = (empty /: elems) (_ + _)
diff --git a/src/library/scala/collection/generic/BuilderFactory.scala b/src/library/scala/collection/generic/BuilderFactory.scala
index 1940865031..27cc6ddfb0 100644
--- a/src/library/scala/collection/generic/BuilderFactory.scala
+++ b/src/library/scala/collection/generic/BuilderFactory.scala
@@ -8,8 +8,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.Builder
/** A base class for builder factories
*/
diff --git a/src/library/scala/collection/generic/Companion.scala b/src/library/scala/collection/generic/GenericCompanion.scala
index 316394b786..a1a165254d 100644
--- a/src/library/scala/collection/generic/Companion.scala
+++ b/src/library/scala/collection/generic/GenericCompanion.scala
@@ -9,11 +9,12 @@
// $Id$
-package scala.collection.generic
+package scala.collection
+package generic
-import scala.collection._
+import mutable.Builder
-abstract class Companion[+CC[X] <: Traversable[X]] {
+abstract class GenericCompanion[+CC[X] <: Traversable[X]] {
type Coll = CC[_]
def newBuilder[A]: Builder[A, CC[A]]
diff --git a/src/library/scala/collection/generic/SetClass.scala b/src/library/scala/collection/generic/GenericSetTemplate.scala
index 7e03ea2441..f51fdcbb6e 100644
--- a/src/library/scala/collection/generic/SetClass.scala
+++ b/src/library/scala/collection/generic/GenericSetTemplate.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
-trait SetClass[A, +CC[X] <: Set[X]] extends TraversableClass[A, CC] {
+trait GenericSetTemplate[A, +CC[X] <: Set[X]] extends GenericTraversableTemplate[A, CC] {
def empty: CC[A] = companion.empty[A]
}
diff --git a/src/library/scala/collection/generic/TraversableClass.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala
index 4d0e44e0d6..886607c458 100644
--- a/src/library/scala/collection/generic/TraversableClass.scala
+++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala
@@ -9,19 +9,20 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+import mutable.Builder
import annotation.unchecked.uncheckedVariance
-trait TraversableClass[+A, +CC[X] <: Traversable[X]] {
+trait GenericTraversableTemplate[+A, +CC[X] <: Traversable[X]] {
def foreach[U](f: A => U): Unit
def head: A
def isEmpty: Boolean
/** The factory companion object that builds instances of class CC */
- def companion: Companion[CC]
+ def companion: GenericCompanion[CC]
/** The builder that builds instances of CC[A] */
protected[this] def newBuilder: Builder[A, CC[A]] = companion.newBuilder[A]
diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala
index 7004952040..70a5b35501 100644
--- a/src/library/scala/collection/generic/Growable.scala
+++ b/src/library/scala/collection/generic/Growable.scala
@@ -8,8 +8,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
/** This class represents collections that can be augmented using a `+=` operator
* and that can be cleared of all elements using the `clear` method.
diff --git a/src/library/scala/collection/generic/ImmutableMapFactory.scala b/src/library/scala/collection/generic/ImmutableMapFactory.scala
index d74048f059..92762fd53b 100644
--- a/src/library/scala/collection/generic/ImmutableMapFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableMapFactory.scala
@@ -8,13 +8,15 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.{Builder, MapBuilder}
/** A template for companion objects of <code>immutable.Map</code> and
* subclasses thereof.
*/
-abstract class ImmutableMapFactory[CC[A, +B] <: immutable.Map[A, B] with ImmutableMapTemplate[A, B, CC[A, B]]]
+abstract class ImmutableMapFactory[CC[A, +B] <: immutable.Map[A, B] with immutable.MapLike[A, B, CC[A, B]]]
extends MapFactory[CC] {
def newBuilder[A, B] = new MapBuilder[A, B, CC[A, B]](empty[A, B])
diff --git a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala
index 447129aab5..ad3980fcb2 100644
--- a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala
@@ -9,12 +9,14 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.{Builder, MapBuilder}
/** A template for companion objects of immutable.Map and subclasses thereof.
*/
-abstract class ImmutableSortedMapFactory[CC[A, B] <: immutable.SortedMap[A, B] with SortedMapTemplate[A, B, CC[A, B]]]
+abstract class ImmutableSortedMapFactory[CC[A, B] <: immutable.SortedMap[A, B] with SortedMapLike[A, B, CC[A, B]]]
extends SortedMapFactory[CC] {
def newBuilder[A, B](implicit ord: Ordering[A]): Builder[(A, B), CC[A, B]] =
diff --git a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala
index 141f3aee6f..7b7f2fcfdf 100644
--- a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala
@@ -9,11 +9,13 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.{Builder, SetBuilder}
/** A template for companion objects of mutable.Map and subclasses thereof.
*/
-abstract class ImmutableSortedSetFactory[CC[A] <: immutable.SortedSet[A] with SortedSetTemplate[A, CC[A]]] extends SortedSetFactory[CC]{
+abstract class ImmutableSortedSetFactory[CC[A] <: immutable.SortedSet[A] with SortedSetLike[A, CC[A]]] extends SortedSetFactory[CC]{
def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]] = new SetBuilder[A, CC[A]](empty)
}
diff --git a/src/library/scala/collection/generic/IterableTemplate.scala b/src/library/scala/collection/generic/IterableTemplate.scala
deleted file mode 100644
index e628783738..0000000000
--- a/src/library/scala/collection/generic/IterableTemplate.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-package scala.collection.generic
-import scala.collection._
-
-/** <p>
- * A template trait for iterable collections.
- * </p>
- * <p>
- * Collection classes mixing in this trait provide a method
- * <code>iterator</code> which returns an iterator over all the
- * elements contained in the collection. They also provide a method
- * <code>newBuilder</code> which creates a builder for collections of the
- * same kind.
- * </p>
- * <p>
- * This trait implements <code>Traversable</code>'s <code>foreach</code>
- * method by stepping through all elements. Subclasses of <code>Iterable</code>
- * should re-implement <code>foreach</code> with something more efficient,
- * if possible.
- * </p>
- * <p>
- * This trait adds methods <code>iterator</code>, <code>sameElements</code>,
- * <code>takeRight</code>, <code>dropRight</code> to the methods inherited
- * from trait <a href="../Traversable.html" target="ContentFrame">
- * <code>Traversable</code></a>.
- * </p>
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait IterableTemplate[+A, +This <: IterableTemplate[A, This] with Iterable[A]]
-extends TraversableTemplate[A, This]
- with IterableLike[A, This]
diff --git a/src/library/scala/collection/generic/KMP.scala b/src/library/scala/collection/generic/KMP.scala
deleted file mode 100644
index a3de9740d9..0000000000
--- a/src/library/scala/collection/generic/KMP.scala
+++ /dev/null
@@ -1,90 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection.generic
-
-/** KMP implementation, based on the undoubtedly reliable wikipedia entry.
- *
- * @author paulp
- */
-object KMP {
-
- private def KMP[B](S: Seq[B], W: Seq[B]): Option[Int] = {
- // trivial cases
- if (W.isEmpty) return Some(0)
- else if (W drop 1 isEmpty) return (S indexOf W(0)) match {
- case -1 => None
- case x => Some(x)
- }
-
- val T: Array[Int] = {
- val arr = new Array[Int](W.length)
- var pos = 2
- var cnd = 0
- arr(0) = -1
- arr(1) = 0
- while (pos < W.length) {
- if (W(pos - 1) == W(cnd)) {
- arr(pos) = cnd + 1
- pos += 1
- cnd += 1
- }
- else if (cnd > 0) {
- cnd = arr(cnd)
- }
- else {
- arr(pos) = 0
- pos += 1
- }
- }
- arr
- }
-
- var m, i = 0
- def mi = m + i
-
- while (mi < S.length) {
- if (W(i) == S(mi)) {
- i += 1
- if (i == W.length)
- return Some(m)
- }
- else {
- m = mi - T(i)
- if (i > 0)
- i = T(i)
- }
- }
- None
- }
-
- def indexOf[B](
- source: Seq[B], sourceOffset: Int, sourceCount: Int,
- target: Seq[B], targetOffset: Int, targetCount: Int,
- fromIndex: Int): Int =
- KMP(source.slice(sourceOffset, sourceCount) drop fromIndex, target.slice(targetOffset, targetCount)) match {
- case None => -1
- case Some(x) => x + fromIndex
- }
-
- def lastIndexOf[B](
- source: Seq[B], sourceOffset: Int, sourceCount: Int,
- target: Seq[B], targetOffset: Int, targetCount: Int,
- fromIndex: Int): Int = {
- val src = (source.slice(sourceOffset, sourceCount) take fromIndex).reverse
- val tgt = target.slice(targetOffset, targetCount).reverse
-
- KMP(src, tgt) match {
- case None => -1
- case Some(x) => (src.length - tgt.length - x) + sourceOffset
- }
- }
-}
diff --git a/src/library/scala/collection/generic/LinearSequenceTemplate.scala b/src/library/scala/collection/generic/LinearSequenceTemplate.scala
deleted file mode 100644
index 3eb4ee598b..0000000000
--- a/src/library/scala/collection/generic/LinearSequenceTemplate.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection.generic
-import scala.collection._
-
-import mutable.ListBuffer
-// import immutable.{List, Nil, ::}
-import generic._
-import scala.util.control.Breaks._
-
-/** Class <code>Linear[A]</code> represents linear sequences of elements.
- * For such sequences `isEmpty`, `head` and `tail` are guaranteed to be
- * efficient constant time (or near so) operations.
- * It does not add any methods to <code>Sequence</code> but overrides
- * several methods with optimized implementations.
- *
- * @author Martin Odersky
- * @author Matthias Zenger
- * @version 1.0, 16/07/2003
- */
-trait LinearSequenceTemplate[+A, +This <: LinearSequenceTemplate[A, This] with LinearSequence[A]] extends LinearSequenceLike[A, This] {
- self: This =>
-}
diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala
index 6caa97b270..941a43b136 100644
--- a/src/library/scala/collection/generic/MapFactory.scala
+++ b/src/library/scala/collection/generic/MapFactory.scala
@@ -9,13 +9,15 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.Builder
/** A template for companion objects of <code>mutable.Map</code> and
* subclasses thereof.
*/
-abstract class MapFactory[CC[A, B] <: Map[A, B] with MapTemplate[A, B, CC[A, B]]] {
+abstract class MapFactory[CC[A, B] <: Map[A, B] with MapLike[A, B, CC[A, B]]] {
type Coll = CC[_, _]
diff --git a/src/library/scala/collection/generic/MutableMapFactory.scala b/src/library/scala/collection/generic/MutableMapFactory.scala
index 0d72339c2c..d506f66400 100644
--- a/src/library/scala/collection/generic/MutableMapFactory.scala
+++ b/src/library/scala/collection/generic/MutableMapFactory.scala
@@ -9,12 +9,14 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.MapBuilder
/** A template for companion objects of mutable.Map and subclasses thereof.
*/
-abstract class MutableMapFactory[CC[A, B] <: mutable.Map[A, B] with MutableMapTemplate[A, B, CC[A, B]]]
+abstract class MutableMapFactory[CC[A, B] <: mutable.Map[A, B] with mutable.MapLike[A, B, CC[A, B]]]
extends MapFactory[CC] {
def newBuilder[A, B] = new MapBuilder[A, B, CC[A, B]](empty[A, B])
diff --git a/src/library/scala/collection/generic/MutableVectorTemplate.scala b/src/library/scala/collection/generic/MutableVectorTemplate.scala
deleted file mode 100644
index c276d3531d..0000000000
--- a/src/library/scala/collection/generic/MutableVectorTemplate.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection.generic
-import scala.collection._
-
-/** A subtrait of collection.Vector which represents sequences
- * that can be mutated.
- */
-trait MutableVectorTemplate[A, +This <: MutableVectorTemplate[A, This] with mutable.Vector[A]] extends VectorTemplate[A, This] { self =>
-
- def update(idx: Int, elem: A)
-
- /** Creates a view of this iterable @see Iterable.View
- */
- override def view = new MutableVectorView[A, This] {
- protected lazy val underlying = self.repr
- override def iterator = self.iterator
- override def length = self.length
- override def apply(idx: Int) = self.apply(idx)
- override def update(idx: Int, elem: A) = self.update(idx, elem)
- }
-
- /** A sub-sequence view starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- * @note The difference between `view` and `slice` is that `view` produces
- * a view of the current sequence, whereas `slice` produces a new sequence.
- *
- * @note view(from, to) is equivalent to view.slice(from, to)
- */
- override def view(from: Int, until: Int) = view.slice(from, until)
-}
diff --git a/src/library/scala/collection/generic/SequenceFactory.scala b/src/library/scala/collection/generic/SequenceFactory.scala
index 4e5c7fba90..525eeb828c 100644
--- a/src/library/scala/collection/generic/SequenceFactory.scala
+++ b/src/library/scala/collection/generic/SequenceFactory.scala
@@ -9,13 +9,12 @@
// $Id$
-package scala.collection.generic
-
-import scala.collection._
+package scala.collection
+package generic
/** A template for companion objects of Sequence and subclasses thereof.
*/
-abstract class SequenceFactory[CC[X] <: Sequence[X] with TraversableClass[X, CC]] extends TraversableFactory[CC] {
+abstract class SequenceFactory[CC[X] <: Sequence[X] with GenericTraversableTemplate[X, CC]] extends TraversableFactory[CC] {
/** This method is called in a pattern match { case Sequence(...) => }.
*
diff --git a/src/library/scala/collection/generic/SequenceTemplate.scala b/src/library/scala/collection/generic/SequenceTemplate.scala
deleted file mode 100644
index df51449528..0000000000
--- a/src/library/scala/collection/generic/SequenceTemplate.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection.generic
-import scala.collection._
-
-import mutable.{ListBuffer, HashMap}
-
-// import immutable.{List, Nil, ::}
-import generic._
-
-/** Class <code>Sequence[A]</code> represents sequences of elements
- * of type <code>A</code>.
- * It adds the following methods to class Iterable:
- * `length`, `lengthCompare`, `apply`, `isDefinedAt`, `segmentLength`, `prefixLength`,
- * `indexWhere`, `indexOf`, `lastIndexWhere`, `lastIndexOf`, `reverse`, `reverseIterator`,
- * `startsWith`, `endsWith`, `indexOfSeq`, , `zip`, `zipAll`, `zipWithIndex`.
- *
- *
- * @author Martin Odersky
- * @author Matthias Zenger
- * @version 1.0, 16/07/2003
- */
-trait SequenceTemplate[+A, +This <: SequenceTemplate[A, This] with Sequence[A]]
-extends IterableTemplate[A, This]
- with SequenceLike[A, This]
diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala
index 4422f58f57..b106285e0d 100644
--- a/src/library/scala/collection/generic/SetFactory.scala
+++ b/src/library/scala/collection/generic/SetFactory.scala
@@ -9,14 +9,16 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.{Builder, AddingBuilder}
/** A template for companion objects of <code>Set</code> and subclasses
* thereof.
*/
-abstract class SetFactory[CC[X] <: Set[X] with SetTemplate[X, CC[X]]]
- extends Companion[CC] {
+abstract class SetFactory[CC[X] <: Set[X] with SetLike[X, CC[X]]]
+ extends GenericCompanion[CC] {
def newBuilder[A]: Builder[A, CC[A]] = new AddingBuilder[A, CC[A]](empty[A])
diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala
index 83b164abac..dc996289d9 100644
--- a/src/library/scala/collection/generic/Shrinkable.scala
+++ b/src/library/scala/collection/generic/Shrinkable.scala
@@ -8,8 +8,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
/** This class represents collections that can be reduced using a -= operator.
*
diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala
index 108255612b..b0cc6907bb 100644
--- a/src/library/scala/collection/generic/Sorted.scala
+++ b/src/library/scala/collection/generic/Sorted.scala
@@ -8,8 +8,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
/** Any collection (including maps) whose keys (or elements) are ordered.
*
diff --git a/src/library/scala/collection/generic/SortedMapFactory.scala b/src/library/scala/collection/generic/SortedMapFactory.scala
index 4ea81a417c..6e1deccf99 100644
--- a/src/library/scala/collection/generic/SortedMapFactory.scala
+++ b/src/library/scala/collection/generic/SortedMapFactory.scala
@@ -9,12 +9,14 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.Builder
/** A template for companion objects of mutable.Map and subclasses thereof.
*/
-abstract class SortedMapFactory[CC[A, B] <: SortedMap[A, B] with SortedMapTemplate[A, B, CC[A, B]]] {
+abstract class SortedMapFactory[CC[A, B] <: SortedMap[A, B] with SortedMapLike[A, B, CC[A, B]]] {
type Coll = CC[_, _]
diff --git a/src/library/scala/collection/generic/SortedSetFactory.scala b/src/library/scala/collection/generic/SortedSetFactory.scala
index 5f813dec7f..fbad5179a6 100644
--- a/src/library/scala/collection/generic/SortedSetFactory.scala
+++ b/src/library/scala/collection/generic/SortedSetFactory.scala
@@ -9,12 +9,14 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
+
+import mutable.Builder
/** A template for companion objects of Set and subclasses thereof.
*/
-abstract class SortedSetFactory[CC[A] <: SortedSet[A] with SortedSetTemplate[A, CC[A]]] {
+abstract class SortedSetFactory[CC[A] <: SortedSet[A] with SortedSetLike[A, CC[A]]] {
type Coll = CC[_]
def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]]
diff --git a/src/library/scala/collection/generic/Subtractable.scala b/src/library/scala/collection/generic/Subtractable.scala
index bdaeb72fe2..bd1a9e9000 100644
--- a/src/library/scala/collection/generic/Subtractable.scala
+++ b/src/library/scala/collection/generic/Subtractable.scala
@@ -8,8 +8,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
/** This class represents collections that can be reduced using a - operator.
*
diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala
index 08633f5e3b..2086befff3 100644
--- a/src/library/scala/collection/generic/TraversableFactory.scala
+++ b/src/library/scala/collection/generic/TraversableFactory.scala
@@ -8,13 +8,13 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package generic
/** A template for companion objects of Traversable and subclasses thereof.
*/
-abstract class TraversableFactory[CC[X] <: Traversable[X] with TraversableClass[X, CC]]
- extends Companion[CC] {
+abstract class TraversableFactory[CC[X] <: Traversable[X] with GenericTraversableTemplate[X, CC]]
+ extends GenericCompanion[CC] {
class VirtualBuilderFactory[A] extends BuilderFactory[A, CC[A], CC[_]] {
def apply(from: Coll) = from.genericBuilder[A]
diff --git a/src/library/scala/collection/generic/TraversableTemplate.scala b/src/library/scala/collection/generic/TraversableTemplate.scala
deleted file mode 100644
index df25f5c264..0000000000
--- a/src/library/scala/collection/generic/TraversableTemplate.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection.generic
-import scala.collection._
-
-/** <p>
- * A template trait for traversable collections.
- * This is a base trait of all kinds of Scala collections. It implements
- * the behavior common to all collections, in terms of a method
- * <code>foreach</code> with signature:
- * </p><pre>
- * <b>def</b> foreach[U](f: Elem => U): Unit</pre>
- * <p>
- * Collection classes mixing in this trait provide a concrete
- * <code>foreach</code> method which traverses all the
- * elements contained in the collection, applying a given function to each.
- * They also need to provide a method <code>newBuilder</code>
- * which creates a builder for collections of the same kind.
- * </p>
- * <p>
- * A traversable class might or might not have two properties: strictness
- * and orderedness. Neither is represented as a type.
- * </p>
- * <p>
- * The instances of a strict collection class have all their elements
- * computed before they can be used as values. By contrast, instances of
- * a non-strict collection class may defer computation of some of their
- * elements until after the instance is available as a value.
- * A typical example of a non-strict collection class is a
- * <a href="../immutable/Stream.html" target="ContentFrame">
- * <code>scala.collection.immutable.Stream</code></a>.
- * A more general class of examples are <code>TraversableViews</code>.
- * </p>
- * <p>
- * If a collection is an instance of an ordered collection class, traversing
- * its elements with <code>foreach</code> will always visit elements in the
- * same order, even for different runs of the program. If the class is not
- * ordered, <code>foreach</code> can visit elements in different orders for
- * different runs (but it will keep the same order in the same run).<br/>
- * A typical example of a collection class which is not ordered is a
- * <code>HashMap</code> of objects. The traversal order for hash maps will
- * depend on the hash codes of its elements, and these hash codes might
- * differ from one run to the next. By contrast, a <code>LinkedHashMap</code>
- * is odered because it's <code>foreach</code> method visits elements in the
- * order they were inserted into the <code>HashMap</code>.
- * </p>
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait TraversableTemplate[+A, +This <: TraversableTemplate[A, This] with Traversable[A]]
-extends TraversableLike[A, This]
-
diff --git a/src/library/scala/collection/generic/VectorTemplate.scala b/src/library/scala/collection/generic/VectorTemplate.scala
deleted file mode 100644
index e55d172f52..0000000000
--- a/src/library/scala/collection/generic/VectorTemplate.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection
-package generic
-
-/** Sequences that support O(1) element access and O(1) length computation.
- * This class does not add any methods to Sequence but overrides several
- * methods with optimized implementations.
- *
- * @author Sean McDirmid
- * @author Martin Odersky
- * @version 2.8
- */
-trait VectorTemplate[+A, +This <: VectorTemplate[A, This] with Vector[A]] extends SequenceTemplate[A, This] with VectorLike[A, This]
diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala
index bd790b777a..494562c50f 100644
--- a/src/library/scala/collection/immutable/BitSet.scala
+++ b/src/library/scala/collection/immutable/BitSet.scala
@@ -9,17 +9,18 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import BitSetTemplate.{LogWL, updateArray}
+import generic._
+import BitSetLike.{LogWL, updateArray}
/** A base class for immutable bit sets.
*/
@serializable @SerialVersionUID(1611436763290191562L)
abstract class BitSet extends Set[Int]
- with collection.BitSet
- with BitSetTemplate[BitSet] {
+ with scala.collection.BitSet
+ with BitSetLike[BitSet] {
override def empty = BitSet.empty
def fromArray(elems: Array[Long]): BitSet = BitSet.fromArray(elems)
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 730c8e1435..bbffd4e05d 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable
+import generic._
import annotation.unchecked.uncheckedVariance
/** <p>
@@ -33,9 +33,9 @@ import annotation.unchecked.uncheckedVariance
* @version 2.0, 19/01/2007
*/
@serializable @SerialVersionUID(8886909077084990906L)
-class HashMap[A, +B] extends Map[A,B] with ImmutableMapTemplate[A, B, HashMap[A, B]] with mutable.HashTable[A] {
+class HashMap[A, +B] extends Map[A,B] with MapLike[A, B, HashMap[A, B]] with mutable.HashTable[A] {
- type Entry = collection.mutable.DefaultEntry[A, Any]
+ type Entry = scala.collection.mutable.DefaultEntry[A, Any]
protected var later: HashMap[A, B @uncheckedVariance] = null
protected var oldKey: A = _
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index 6589e83e92..4ce78f75d4 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable
+import generic._
/** <p>
* This class implements immutable sets using a hash table.
@@ -33,10 +33,10 @@ import scala.collection.mutable
*/
@serializable @SerialVersionUID(4020728942921483037L)
class HashSet[A] extends Set[A]
- with SetClass[A, HashSet]
- with SetTemplate[A, HashSet[A]]
+ with GenericSetTemplate[A, HashSet]
+ with SetLike[A, HashSet[A]]
with mutable.FlatHashTable[A] {
- override def companion: Companion[HashSet] = HashSet
+ override def companion: GenericCompanion[HashSet] = HashSet
protected var later: HashSet[A] = null
protected var changedElem: A = _
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index b93a778385..5d7d385d8c 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.immutable;
+package scala.collection
+package immutable;
/**
* @author David MacIver
@@ -147,7 +148,7 @@ import IntMap._
* <a href="http://citeseer.ist.psu.edu/okasaki98fast.html">Fast Mergeable Integer Maps</a>
* by Okasaki and Gill. Essentially a trie based on binary digits of the the integers.
*/
-sealed abstract class IntMap[+T] extends scala.collection.immutable.Map[Int, T] with scala.collection.generic.ImmutableMapTemplate[Int, T, IntMap[T]] {
+sealed abstract class IntMap[+T] extends Map[Int, T] with MapLike[Int, T, IntMap[T]] {
override def empty: IntMap[T] = IntMap.Nil;
override def toList = {
diff --git a/src/library/scala/collection/immutable/Iterable.scala b/src/library/scala/collection/immutable/Iterable.scala
index 4a85779443..ac4f7701b5 100644
--- a/src/library/scala/collection/immutable/Iterable.scala
+++ b/src/library/scala/collection/immutable/Iterable.scala
@@ -9,12 +9,13 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable
+import generic._
+import mutable.Builder
-/** A subtrait of collection.Iterable which represents iterables
+/** A subtrait of scala.collection.Iterable which represents iterables
* that cannot be mutated.
*
* @author Matthias Zenger
@@ -22,10 +23,10 @@ import scala.collection.mutable
* @version 2.8
*/
trait Iterable[+A] extends Traversable[A]
- with collection.Iterable[A]
- with TraversableClass[A, Iterable]
- with IterableTemplate[A, Iterable[A]] {
- override def companion: Companion[Iterable] = Iterable
+ with scala.collection.Iterable[A]
+ with GenericTraversableTemplate[A, Iterable]
+ with IterableLike[A, Iterable[A]] {
+ override def companion: GenericCompanion[Iterable] = Iterable
}
/** A factory object for the trait <code>Iterable</code>.
diff --git a/src/library/scala/collection/immutable/LinearSequence.scala b/src/library/scala/collection/immutable/LinearSequence.scala
index 073a3691ca..303e24aa5a 100644
--- a/src/library/scala/collection/immutable/LinearSequence.scala
+++ b/src/library/scala/collection/immutable/LinearSequence.scala
@@ -9,19 +9,20 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable
+import generic._
+import mutable.Builder
/** A subtrait of <code>collection.Sequence</code> which represents sequences
* that cannot be mutated.
*/
trait LinearSequence[+A] extends Sequence[A]
- with collection.LinearSequence[A]
- with TraversableClass[A, LinearSequence]
- with LinearSequenceTemplate[A, LinearSequence[A]] {
- override def companion: Companion[LinearSequence] = LinearSequence
+ with scala.collection.LinearSequence[A]
+ with GenericTraversableTemplate[A, LinearSequence]
+ with LinearSequenceLike[A, LinearSequence[A]] {
+ override def companion: GenericCompanion[LinearSequence] = LinearSequence
}
object LinearSequence extends SequenceFactory[LinearSequence] {
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 44736821e9..6aedee2f25 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -9,10 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.mutable.ListBuffer
-import scala.collection.generic._
+import generic._
+import mutable.{Builder, ListBuffer}
import annotation.tailrec
/** A class representing an ordered collection of elements of type
@@ -26,11 +27,11 @@ import annotation.tailrec
*/
sealed abstract class List[+A] extends LinearSequence[A]
with Product
- with TraversableClass[A, List]
- with LinearSequenceTemplate[A, List[A]] {
- override def companion: Companion[List] = List
+ with GenericTraversableTemplate[A, List]
+ with LinearSequenceLike[A, List[A]] {
+ override def companion: GenericCompanion[List] = List
- import collection.{Iterable, Traversable, Sequence, Vector}
+ import scala.collection.{Iterable, Traversable, Sequence, Vector}
/** Returns true if the list does not contain any elements.
* @return <code>true</code>, iff the list is empty.
@@ -140,7 +141,7 @@ sealed abstract class List[+A] extends LinearSequence[A]
loop(this)
}
- // Overridden methods from IterableTemplate or overloaded variants of such methods
+ // Overridden methods from IterableLike or overloaded variants of such methods
/** Create a new list which contains all elements of this list
* followed by all elements of Traversable `that'
@@ -224,6 +225,8 @@ sealed abstract class List[+A] extends LinearSequence[A]
loop(drop(n), this)
}
+ // dropRight is inherited from Stream
+
/** Split the list at a given point and return the two parts thus
* created.
*
@@ -354,7 +357,7 @@ sealed abstract class List[+A] extends LinearSequence[A]
* <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
* which should be true iff <code>e1</code> is smaller than
* <code>e2</code>.
- * !!! todo: move sorting to IterableTemplate
+ * !!! todo: move sorting to IterableLike
* </p>
*
* @param lt the comparison function
@@ -429,9 +432,6 @@ sealed abstract class List[+A] extends LinearSequence[A]
ms(this)
}
- // !!! The above sort could be replaced by:
- // def sort(lt: (A, A) => Boolean): List[A] = super.sortWith(lt)
- // except that it fails to find a ClassManifest.
}
/** The empty list.
@@ -496,7 +496,7 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend
*/
object List extends SequenceFactory[List] {
- import collection.{Iterable, Sequence, Vector}
+ import scala.collection.{Iterable, Sequence, Vector}
implicit def builderFactory[A]: BuilderFactory[A, List[A], Coll] = new VirtualBuilderFactory[A]
def newBuilder[A]: Builder[A, List[A]] = new ListBuffer[A]
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index c991318872..5f95d4679f 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
/** The canonical factory of <a href="ListMap.html">ListMap</a>'s.
*/
@@ -31,7 +32,7 @@ object ListMap extends ImmutableMapFactory[ListMap] {
* @version 2.0, 01/01/2007
*/
@serializable @SerialVersionUID(301002838095710379L)
-class ListMap[A, +B] extends Map[A, B] with ImmutableMapTemplate[A, B, ListMap[A, B]] {
+class ListMap[A, +B] extends Map[A, B] with MapLike[A, B, ListMap[A, B]] {
override def empty = ListMap.empty
diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala
index d3eac8f9f9..98eae7d08e 100644
--- a/src/library/scala/collection/immutable/ListSet.scala
+++ b/src/library/scala/collection/immutable/ListSet.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
/** The canonical factory of <a href="ListSet.html">ListSet</a>'s */
object ListSet extends SetFactory[ListSet] {
@@ -30,9 +31,9 @@ object ListSet extends SetFactory[ListSet] {
*/
@serializable
class ListSet[A] extends Set[A]
- with SetClass[A, ListSet]
- with SetTemplate[A, ListSet[A]] { self =>
- override def companion: Companion[ListSet] = ListSet
+ with GenericSetTemplate[A, ListSet]
+ with SetLike[A, ListSet[A]] { self =>
+ override def companion: GenericCompanion[ListSet] = ListSet
/** Returns the number of elements in this set.
*
diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala
index d553329114..956142e54c 100644
--- a/src/library/scala/collection/immutable/LongMap.scala
+++ b/src/library/scala/collection/immutable/LongMap.scala
@@ -1,4 +1,5 @@
-package scala.collection.immutable;
+package scala.collection
+package immutable
/**
* @author David MacIver
@@ -134,7 +135,7 @@ import LongMap._;
* <a href="http://citeseer.ist.psu.edu/okasaki98fast.html">Fast Mergeable Long Maps</a>
* by Okasaki and Gill. Essentially a trie based on binary digits of the the integers.
*/
-sealed abstract class LongMap[+T] extends scala.collection.immutable.Map[Long, T] with scala.collection.generic.ImmutableMapTemplate[Long, T, LongMap[T]] {
+sealed abstract class LongMap[+T] extends Map[Long, T] with MapLike[Long, T, LongMap[T]] {
override def empty: LongMap[T] = LongMap.Nil;
override def toList = {
diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala
index 1117496b81..25d2ac5b80 100644
--- a/src/library/scala/collection/immutable/Map.scala
+++ b/src/library/scala/collection/immutable/Map.scala
@@ -9,13 +9,14 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
trait Map[A, +B] extends Iterable[(A, B)]
- with collection.Map[A, B]
- with ImmutableMapTemplate[A, B, Map[A, B]] { self =>
+ with scala.collection.Map[A, B]
+ with MapLike[A, B, Map[A, B]] { self =>
override def empty: Map[A, B] = Map.empty
diff --git a/src/library/scala/collection/generic/ImmutableMapTemplate.scala b/src/library/scala/collection/immutable/MapLike.scala
index 70a55438d9..2f8be4c4d5 100644
--- a/src/library/scala/collection/generic/ImmutableMapTemplate.scala
+++ b/src/library/scala/collection/immutable/MapLike.scala
@@ -9,8 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package immutable
+
+import generic._
/** <p>
* A generic template for immutable maps from keys of type <code>A</code>
@@ -38,10 +40,11 @@ import scala.collection._
* @author Martin Odersky
* @version 2.8
*/
-trait ImmutableMapTemplate[A, +B, +This <: ImmutableMapTemplate[A, B, This] with immutable.Map[A, B]]
- extends MapTemplate[A, B, This] {
+trait MapLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]] extends scala.collection.MapLike[A, B, This] {
self =>
+ import scala.collection.Traversable
+
/** A new immutable map containing updating this map with a given key/value mapping.
* @param key the key
* @param value the value
diff --git a/src/library/scala/collection/immutable/MapProxy.scala b/src/library/scala/collection/immutable/MapProxy.scala
index de3474a2d0..b17a3bf5a0 100644
--- a/src/library/scala/collection/immutable/MapProxy.scala
+++ b/src/library/scala/collection/immutable/MapProxy.scala
@@ -9,9 +9,8 @@
// $Id$
-package scala.collection.immutable
-
-import scala.collection.generic.MapProxyTemplate
+package scala.collection
+package immutable
/** <p>
* This is a simple wrapper class for <a href="Map.html"
@@ -25,7 +24,7 @@ import scala.collection.generic.MapProxyTemplate
* @author Matthias Zenger, Martin Odersky
* @version 2.0, 31/12/2006
*/
-trait MapProxy[A, +B] extends Map[A, B] with MapProxyTemplate[A, B, Map[A, B]]
+trait MapProxy[A, +B] extends Map[A, B] with MapProxyLike[A, B, Map[A, B]]
{
override def repr = this
private def newProxy[B1 >: B](newSelf: Map[A, B1]): MapProxy[A, B1] =
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index e45675fd31..53e7007d8e 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
import java.io._
import scala.util.matching.Regex
@@ -112,7 +113,7 @@ class PagedSeq[T: ClassManifest] protected(
first1: Page[T],
start: Int,
end: Int)
-extends collection.Vector[T]
+extends scala.collection.Vector[T]
{
/** A paged sequence is constructed from a method that produces more characters when asked.
* The producer method is analogous to the read method in java.io.Reader.
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 343c4d2779..2854e62ae9 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
import scala.annotation.tailrec
diff --git a/src/library/scala/collection/immutable/RedBlack.scala b/src/library/scala/collection/immutable/RedBlack.scala
index 0ff253045e..17b7746260 100644
--- a/src/library/scala/collection/immutable/RedBlack.scala
+++ b/src/library/scala/collection/immutable/RedBlack.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
@serializable @SerialVersionUID(8691885935445612921L)
abstract class RedBlack[A] {
diff --git a/src/library/scala/collection/immutable/Sequence.scala b/src/library/scala/collection/immutable/Sequence.scala
index 3ce7cd3b00..35b236ee99 100644
--- a/src/library/scala/collection/immutable/Sequence.scala
+++ b/src/library/scala/collection/immutable/Sequence.scala
@@ -9,19 +9,20 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable
+import generic._
+import mutable.Builder
/** A subtrait of collection.Sequence which represents sequences
* that cannot be mutated.
*/
trait Sequence[+A] extends Iterable[A]
- with collection.Sequence[A]
- with TraversableClass[A, Sequence]
- with SequenceTemplate[A, Sequence[A]] {
- override def companion: Companion[Sequence] = Sequence
+ with scala.collection.Sequence[A]
+ with GenericTraversableTemplate[A, Sequence]
+ with SequenceLike[A, Sequence[A]] {
+ override def companion: GenericCompanion[Sequence] = Sequence
}
object Sequence extends SequenceFactory[Sequence] {
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index e9e492baa4..4ea067edb5 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
/** <p>
* A generic trait for immutable sets. Concrete set implementations have
@@ -31,10 +32,10 @@ import scala.collection.generic._
* @version 2.8
*/
trait Set[A] extends Iterable[A]
- with collection.Set[A]
- with SetClass[A, Set]
- with SetTemplate[A, Set[A]] {
- override def companion: Companion[Set] = Set
+ with scala.collection.Set[A]
+ with GenericSetTemplate[A, Set]
+ with SetLike[A, Set[A]] {
+ override def companion: GenericCompanion[Set] = Set
}
object Set extends SetFactory[Set] {
diff --git a/src/library/scala/collection/immutable/SetProxy.scala b/src/library/scala/collection/immutable/SetProxy.scala
index 55acfe0236..01e6208423 100644
--- a/src/library/scala/collection/immutable/SetProxy.scala
+++ b/src/library/scala/collection/immutable/SetProxy.scala
@@ -9,9 +9,8 @@
// $Id$
-package scala.collection.immutable
-
-import scala.collection.generic.SetProxyTemplate
+package scala.collection
+package immutable
/** <p>
* This is a simple wrapper class for <a href="Set.html"
@@ -22,7 +21,7 @@ import scala.collection.generic.SetProxyTemplate
* dynamically using object composition and forwarding.
* </p>
*/
-trait SetProxy[A] extends Set[A] with SetProxyTemplate[A, Set[A]]
+trait SetProxy[A] extends Set[A] with SetProxyLike[A, Set[A]]
{
override def repr = this
private def newProxy[B >: A](newSelf: Set[B]): SetProxy[B] =
diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala
index 4f3bbf6c0d..29b5e218de 100644
--- a/src/library/scala/collection/immutable/SortedMap.scala
+++ b/src/library/scala/collection/immutable/SortedMap.scala
@@ -9,9 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
+import mutable.Builder
import annotation.unchecked.uncheckedVariance
/** A map whose keys are sorted.
@@ -21,9 +23,9 @@ import annotation.unchecked.uncheckedVariance
* @version 2.8
*/
trait SortedMap[A, +B] extends Map[A, B]
- with collection.SortedMap[A, B]
- with ImmutableMapTemplate[A, B, SortedMap[A, B]]
- with SortedMapTemplate[A, B, SortedMap[A, B]] {
+ with scala.collection.SortedMap[A, B]
+ with MapLike[A, B, SortedMap[A, B]]
+ with SortedMapLike[A, B, SortedMap[A, B]] {
override protected[this] def newBuilder : Builder[(A, B), SortedMap[A, B]] =
SortedMap.newBuilder[A, B]
@@ -53,7 +55,7 @@ trait SortedMap[A, +B] extends Map[A, B]
*
* @param elems the traversable object.
*/
- override def ++[B1 >: B](elems: collection.Traversable[(A, B1)]): SortedMap[A, B1] =
+ override def ++[B1 >: B](elems: scala.collection.Traversable[(A, B1)]): SortedMap[A, B1] =
((repr: SortedMap[A, B1]) /: elems) (_ + _)
/** Adds a number of elements provided by an iterator
diff --git a/src/library/scala/collection/immutable/SortedSet.scala b/src/library/scala/collection/immutable/SortedSet.scala
index d2afc58cf2..7d01de95d3 100644
--- a/src/library/scala/collection/immutable/SortedSet.scala
+++ b/src/library/scala/collection/immutable/SortedSet.scala
@@ -9,9 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
+import mutable.Builder
/** A sorted set.
*
@@ -19,7 +21,7 @@ import scala.collection.generic._
* @author Martin Odersky
* @version 2.8
*/
-trait SortedSet[A] extends Set[A] with collection.SortedSet[A] with SortedSetTemplate[A, SortedSet[A]] {
+trait SortedSet[A] extends Set[A] with scala.collection.SortedSet[A] with SortedSetLike[A, SortedSet[A]] {
/** Needs to be overridden in subclasses. */
override def empty: SortedSet[A] = throw new UnsupportedOperationException("SortedMap.empty")
}
diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala
index 779e727623..d4df92b4c0 100644
--- a/src/library/scala/collection/immutable/Stack.scala
+++ b/src/library/scala/collection/immutable/Stack.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
import scala.annotation.tailrec
@@ -79,7 +80,7 @@ class Stack[+A] protected (protected val elems: List[A]) extends Sequence[A] {
* @param elems the iterable object.
* @return the stack with the new elements on top.
*/
- def pushAll[B >: A](elems: collection.Traversable[B]): Stack[B] =
+ def pushAll[B >: A](elems: scala.collection.Traversable[B]): Stack[B] =
((this: Stack[B]) /: elems)(_ push _)
/** Returns the top element of the stack. An error is signaled if
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 7a52fde6ab..e5555bda4f 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -9,10 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.mutable.ListBuffer
-import scala.collection.generic._
+import generic._
+import mutable.{Builder, LazyBuilder, ListBuffer}
import scala.annotation.tailrec
/**
@@ -37,12 +38,12 @@ import scala.annotation.tailrec
* @version 1.1 08/08/03
*/
abstract class Stream[+A] extends LinearSequence[A]
- with TraversableClass[A, Stream]
- with LinearSequenceTemplate[A, Stream[A]] {
+ with GenericTraversableTemplate[A, Stream]
+ with LinearSequenceLike[A, Stream[A]] {
self =>
- override def companion: Companion[Stream] = Stream
+ override def companion: GenericCompanion[Stream] = Stream
- import collection.{Traversable, Iterable, Sequence, Vector}
+ import scala.collection.{Traversable, Iterable, Sequence, Vector}
/** is this stream empty? */
def isEmpty: Boolean
@@ -412,14 +413,14 @@ object Stream extends SequenceFactory[Stream] {
/** Creates a new builder for a stream */
def newBuilder[A]: Builder[A, Stream[A]] = new StreamBuilder[A]
- import collection.{Iterable, Sequence, Vector}
+ import scala.collection.{Iterable, Sequence, Vector}
/** A builder for streams
* @note: This builder is lazy only in the sense that it does not go downs the spine
* of traversables taht are added as a whole. If more layzness can be achieved,
* this builder should be bypassed.
*/
- class StreamBuilder[A] extends LazyBuilder[A, Stream[A]] {
+ class StreamBuilder[A] extends scala.collection.mutable.LazyBuilder[A, Stream[A]] {
def result: Stream[A] = (for (xs <- parts.iterator; x <- xs.toIterable.iterator) yield x).toStream
}
@@ -553,7 +554,7 @@ object Stream extends SequenceFactory[Stream] {
/** The concatenation of all streams returned by an iterator
*/
@deprecated("use xs.toStream.flatten instead")
- def concat[A](xs: Iterator[Stream[A]]): Stream[A] = xs.toStream.flatten //(conforms[Stream[A], collection.Traversable[A]])
+ def concat[A](xs: Iterator[Stream[A]]): Stream[A] = xs.toStream.flatten //(conforms[Stream[A], scala.collection.Traversable[A]])
/**
* Create a stream with element values
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala
index 79f27f8a70..f45acc1506 100644
--- a/src/library/scala/collection/immutable/StringLike.scala
+++ b/src/library/scala/collection/immutable/StringLike.scala
@@ -12,8 +12,9 @@
package scala.collection
package immutable
-import scala.util.matching.Regex
import generic._
+import mutable.Builder
+import scala.util.matching.Regex
object StringLike {
diff --git a/src/library/scala/collection/immutable/Traversable.scala b/src/library/scala/collection/immutable/Traversable.scala
index eca6115491..e2c960140c 100644
--- a/src/library/scala/collection/immutable/Traversable.scala
+++ b/src/library/scala/collection/immutable/Traversable.scala
@@ -9,10 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable
+import generic._
+import mutable.Builder
/** A subtrait of <code>collection.Traversable</code> which represents
* traversables that cannot be mutated.
@@ -21,11 +22,11 @@ import scala.collection.mutable
* @author Martin Odersky
* @version 2.8
*/
-trait Traversable[+A] extends collection.Traversable[A]
- with TraversableClass[A, Traversable]
- with TraversableTemplate[A, Traversable[A]]
+trait Traversable[+A] extends scala.collection.Traversable[A]
+ with GenericTraversableTemplate[A, Traversable]
+ with TraversableLike[A, Traversable[A]]
with Immutable {
- override def companion: Companion[Traversable] = Traversable
+ override def companion: GenericCompanion[Traversable] = Traversable
}
/** A factory object for the trait <code>Traversable</code>.
diff --git a/src/library/scala/collection/immutable/TreeHashMap.scala b/src/library/scala/collection/immutable/TreeHashMap.scala
index bf78b606e7..d991df196f 100644
--- a/src/library/scala/collection/immutable/TreeHashMap.scala
+++ b/src/library/scala/collection/immutable/TreeHashMap.scala
@@ -8,7 +8,8 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
// A dummy to fool ant until reintegration.
class TreeHashMap
@@ -39,7 +40,7 @@ object TreeHashMap {
*
* @author David MacIver
*/
-class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap[Key, Value]]) extends scala.collection.immutable.Map[Key, Value]{
+class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap[Key, Value]]) extends Map[Key, Value]{
def iterator : Iterator[(Key, Value)] = new Iterator[(Key, Value)]{
val assocIt = new AssocMapIterator(AssocMap.empty[Key, Value]);
val intIterator = underlying.values;
diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala
index 90f8fe9827..7de19754f0 100644
--- a/src/library/scala/collection/immutable/TreeMap.scala
+++ b/src/library/scala/collection/immutable/TreeMap.scala
@@ -9,9 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
+import mutable.Builder
/** The canonical factory of <a href="TreeMap.html">TreeMap</a>'s. */
object TreeMap extends ImmutableSortedMapFactory[TreeMap] {
@@ -30,8 +32,8 @@ object TreeMap extends ImmutableSortedMapFactory[TreeMap] {
class TreeMap[A, +B](override val size: Int, t: RedBlack[A]#Tree[B])(implicit val ordering: Ordering[A])
extends RedBlack[A]
with SortedMap[A, B]
- with SortedMapTemplate[A, B, TreeMap[A, B]]
- with ImmutableMapTemplate[A, B, TreeMap[A, B]] {
+ with SortedMapLike[A, B, TreeMap[A, B]]
+ with MapLike[A, B, TreeMap[A, B]] {
def isSmaller(x: A, y: A) = ordering.lt(x, y)
diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala
index 58d1bddba5..395eb679a6 100644
--- a/src/library/scala/collection/immutable/TreeSet.scala
+++ b/src/library/scala/collection/immutable/TreeSet.scala
@@ -9,9 +9,11 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
+import generic._
+import mutable.{Builder, AddingBuilder}
/** The canonical factory of <a href="TreeSet.html">TreeSet</a>'s.
*/
@@ -35,7 +37,7 @@ object TreeSet extends SortedSetFactory[TreeSet]{
@serializable @SerialVersionUID(-234066569443569402L)
class TreeSet[A](override val size: Int, t: RedBlack[A]#Tree[Unit])
(implicit val ordering: Ordering[A])
- extends RedBlack[A] with SortedSet[A] with SortedSetTemplate[A, TreeSet[A]] {
+ extends RedBlack[A] with SortedSet[A] with SortedSetLike[A, TreeSet[A]] {
override def stringPrefix = "TreeSet"
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala
index ff224507ee..a496aefa0b 100644
--- a/src/library/scala/collection/immutable/Vector.scala
+++ b/src/library/scala/collection/immutable/Vector.scala
@@ -9,19 +9,20 @@
// $Id$
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.generic._
-import scala.collection.mutable.ArrayBuffer
+import generic._
+import mutable.{Builder, ArrayBuffer}
/** A subtrait of <code>collection.Vector</code> which represents sequences
* that cannot be mutated.
*/
trait Vector[+A] extends Sequence[A]
- with collection.Vector[A]
- with TraversableClass[A, Vector]
- with VectorTemplate[A, Vector[A]] {
- override def companion: Companion[Vector] = Vector
+ with scala.collection.Vector[A]
+ with GenericTraversableTemplate[A, Vector]
+ with VectorLike[A, Vector[A]] {
+ override def companion: GenericCompanion[Vector] = Vector
}
object Vector extends SequenceFactory[Vector] {
diff --git a/src/library/scala/collection/immutable/WrappedString.scala b/src/library/scala/collection/immutable/WrappedString.scala
index 39f55a2344..42b2c7292b 100644
--- a/src/library/scala/collection/immutable/WrappedString.scala
+++ b/src/library/scala/collection/immutable/WrappedString.scala
@@ -12,8 +12,9 @@
package scala.collection
package immutable
-import scala.util.matching.Regex
import generic._
+import mutable.Builder
+import scala.util.matching.Regex
class WrappedString(override val self: String) extends Vector[Char] with StringLike[WrappedString] with Proxy {
diff --git a/src/library/scala/collection/interfaces/IterableMethods.scala b/src/library/scala/collection/interfaces/IterableMethods.scala
index 76d0db04d1..e8285f7f8b 100644
--- a/src/library/scala/collection/interfaces/IterableMethods.scala
+++ b/src/library/scala/collection/interfaces/IterableMethods.scala
@@ -6,15 +6,15 @@
** |/ **
\* */
-package scala.collection.interfaces
+package scala.collection
+package interfaces
-import scala.collection._
import generic._
import mutable.Buffer
import scala.reflect.ClassManifest
import annotation.unchecked.uncheckedVariance
-trait IterableMethods[+A, +This <: IterableTemplate[A, This] with Iterable[A]] extends TraversableMethods[A, This]
+trait IterableMethods[+A, +This <: IterableLike[A, This] with Iterable[A]] extends TraversableMethods[A, This]
{
// abstract
def iterator: Iterator[A]
diff --git a/src/library/scala/collection/interfaces/MapMethods.scala b/src/library/scala/collection/interfaces/MapMethods.scala
index ae1388ac6d..9777b9d8e8 100644
--- a/src/library/scala/collection/interfaces/MapMethods.scala
+++ b/src/library/scala/collection/interfaces/MapMethods.scala
@@ -6,12 +6,12 @@
** |/ **
\* */
-package scala.collection.interfaces
+package scala.collection
+package interfaces
-import scala.collection._
import generic._
-trait MapMethods[A, +B, +This <: MapTemplate[A, B, This] with Map[A, B]]
+trait MapMethods[A, +B, +This <: MapLike[A, B, This] with Map[A, B]]
extends IterableMethods[(A, B), This]
with SubtractableMethods[A, This]
{
diff --git a/src/library/scala/collection/interfaces/SequenceMethods.scala b/src/library/scala/collection/interfaces/SequenceMethods.scala
index 7ba91627af..fe8e361ae6 100644
--- a/src/library/scala/collection/interfaces/SequenceMethods.scala
+++ b/src/library/scala/collection/interfaces/SequenceMethods.scala
@@ -6,14 +6,14 @@
** |/ **
\* */
-package scala.collection.interfaces
+package scala.collection
+package interfaces
-import scala.collection._
import generic._
import mutable.Buffer
import scala.reflect.ClassManifest
-trait SequenceMethods[+A, +This <: SequenceTemplate[A, This] with Sequence[A]] extends IterableMethods[A, This]
+trait SequenceMethods[+A, +This <: SequenceLike[A, This] with Sequence[A]] extends IterableMethods[A, This]
{
// abstract
def apply(idx: Int): A
diff --git a/src/library/scala/collection/interfaces/SetMethods.scala b/src/library/scala/collection/interfaces/SetMethods.scala
index 0f895d16be..23320f3058 100644
--- a/src/library/scala/collection/interfaces/SetMethods.scala
+++ b/src/library/scala/collection/interfaces/SetMethods.scala
@@ -6,9 +6,9 @@
** |/ **
\* */
-package scala.collection.interfaces
+package scala.collection
+package interfaces
-import scala.collection._
import generic._
import mutable.Buffer
import scala.reflect.ClassManifest
@@ -30,7 +30,7 @@ trait SubtractableMethods[A, +This <: Subtractable[A, This]] {
def --(iter: Iterator[A]): This
}
-trait SetMethods[A, +This <: SetTemplate[A, This] with Set[A]]
+trait SetMethods[A, +This <: SetLike[A, This] with Set[A]]
extends IterableMethods[A, This]
with AddableMethods[A, This]
with SubtractableMethods[A, This]
diff --git a/src/library/scala/collection/interfaces/TraversableMethods.scala b/src/library/scala/collection/interfaces/TraversableMethods.scala
index 6722429318..56fb4c0395 100644
--- a/src/library/scala/collection/interfaces/TraversableMethods.scala
+++ b/src/library/scala/collection/interfaces/TraversableMethods.scala
@@ -6,14 +6,14 @@
** |/ **
\* */
-package scala.collection.interfaces
+package scala.collection
+package interfaces
-import scala.collection._
import generic._
import mutable.Buffer
import scala.reflect.ClassManifest
-trait TraversableMethods[+A, +This <: TraversableTemplate[A, This] with Traversable[A]]
+trait TraversableMethods[+A, +This <: TraversableLike[A, This] with Traversable[A]]
{
// abstract
def foreach[U](f: A => U): Unit
diff --git a/src/library/scala/collection/generic/AddingBuilder.scala b/src/library/scala/collection/mutable/AddingBuilder.scala
index fbb195646a..a2729c9c0f 100644
--- a/src/library/scala/collection/generic/AddingBuilder.scala
+++ b/src/library/scala/collection/mutable/AddingBuilder.scala
@@ -8,17 +8,17 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
-// import collection.immutable.{List, Nil, ::}
+import generic._
/** The canonical builder for collections that are addable, i.e. that support an efficient + method
* which adds an element to the collection.
* Collections are built from their empty element using this + method.
* @param empty The empty element of the collection.
*/
-class AddingBuilder[A, Coll <: Addable[A, Coll] with Iterable[A] with IterableTemplate[A, Coll]](empty: Coll)
+class AddingBuilder[A, Coll <: Addable[A, Coll] with scala.collection.Iterable[A] with scala.collection.IterableLike[A, Coll]](empty: Coll)
extends Builder[A, Coll] {
protected var elems: Coll = empty
def +=(x: A): this.type = { elems = elems + x; this }
diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala
index d47a7cec9e..7555cc7a00 100644
--- a/src/library/scala/collection/mutable/ArrayBuffer.scala
+++ b/src/library/scala/collection/mutable/ArrayBuffer.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** An implementation of the <code>Buffer</code> class using an array to
* represent the assembled sequence internally. Append, update and random
@@ -25,15 +26,15 @@ import scala.collection.generic._
@serializable @SerialVersionUID(1529165946227428979L)
class ArrayBuffer[A](override protected val initialSize: Int)
extends Buffer[A]
- with TraversableClass[A, ArrayBuffer]
- with BufferTemplate[A, ArrayBuffer[A]]
- with VectorTemplate[A, ArrayBuffer[A]]
+ with GenericTraversableTemplate[A, ArrayBuffer]
+ with BufferLike[A, ArrayBuffer[A]]
+ with VectorLike[A, ArrayBuffer[A]]
with Builder[A, ArrayBuffer[A]]
with ResizableArray[A] {
- override def companion: Companion[ArrayBuffer] = ArrayBuffer
+ override def companion: GenericCompanion[ArrayBuffer] = ArrayBuffer
- import collection.Traversable
+ import scala.collection.Traversable
def this() = this(16)
diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala
index 417d9ceee5..55babd00dd 100644
--- a/src/library/scala/collection/mutable/ArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/ArrayBuilder.scala
@@ -9,11 +9,11 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
import scala.reflect.ClassManifest
-import scala.runtime.BoxedArray
/** A builder class for arrays */
abstract class ArrayBuilder[T] extends Builder[T, Array[T]]
diff --git a/src/library/scala/collection/mutable/ArrayLike.scala b/src/library/scala/collection/mutable/ArrayLike.scala
index 0146fa8cd5..072bd9e6b8 100644
--- a/src/library/scala/collection/mutable/ArrayLike.scala
+++ b/src/library/scala/collection/mutable/ArrayLike.scala
@@ -27,7 +27,7 @@ trait ArrayLike[A, +Repr] extends VectorLike[A, Repr] { self =>
* Example: Array(Array(1, 2), Array(3, 4)).deep.toString
* prints: Array(Array(1, 2), Array(3, 4))
*/
- def deep: scala.collection.Vector[Any] = new collection.Vector[Any] {
+ def deep: scala.collection.Vector[Any] = new scala.collection.Vector[Any] {
def length = self.length
def apply(idx: Int): Any = self.apply(idx) match {
case x: AnyRef if x.getClass.isArray => WrappedArray.make(x).deep
diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala
index 96d35eb8d8..7e2af4d14b 100644
--- a/src/library/scala/collection/mutable/ArrayOps.scala
+++ b/src/library/scala/collection/mutable/ArrayOps.scala
@@ -12,8 +12,6 @@
package scala.collection
package mutable
-import generic.Builder
-
import scala.reflect.ClassManifest
abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] {
diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala
index 5401b2f2de..83be199f08 100644
--- a/src/library/scala/collection/mutable/ArrayStack.scala
+++ b/src/library/scala/collection/mutable/ArrayStack.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
private object Utils {
def growArray(x: Array[AnyRef]) = {
@@ -35,7 +36,7 @@ private object Utils {
*/
@cloneable
class ArrayStack[T] private(private var table : Array[AnyRef],
- private var index : Int) extends collection.Sequence[T] with Cloneable[ArrayStack[T]] {
+ private var index : Int) extends scala.collection.Sequence[T] with Cloneable[ArrayStack[T]] {
def this() = this(new Array[AnyRef](1), 0)
/** Retrieve n'th element from stack, where top of stack has index 0 */
@@ -102,7 +103,7 @@ class ArrayStack[T] private(private var table : Array[AnyRef],
*
* @param x The source of elements to push
*/
- def ++=(x: collection.Iterable[T]): this.type = { x.foreach(this +=(_)); this }
+ def ++=(x: scala.collection.Iterable[T]): this.type = { x.foreach(this +=(_)); this }
/**
diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala
index d3cb8a747e..799f28c1ab 100644
--- a/src/library/scala/collection/mutable/BitSet.scala
+++ b/src/library/scala/collection/mutable/BitSet.scala
@@ -9,19 +9,19 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
-import scala.collection.immutable
-import BitSetTemplate.{LogWL, updateArray}
+import generic._
+import BitSetLike.{LogWL, updateArray}
/** A class for mutable bitsets.
*/
@serializable @SerialVersionUID(8483111450368547763L)
class BitSet(protected var elems: Array[Long]) extends Set[Int]
- with collection.BitSet
- with BitSetTemplate[BitSet]
- with MutableSetTemplate[Int, BitSet] {
+ with scala.collection.BitSet
+ with BitSetLike[BitSet]
+ with SetLike[Int, BitSet] {
override def empty = BitSet.empty
diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala
index 4264bcad00..453150ee67 100644
--- a/src/library/scala/collection/mutable/Buffer.scala
+++ b/src/library/scala/collection/mutable/Buffer.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** Buffers are used to create sequences of elements incrementally by
* appending, prepending, or inserting new elements. It is also
@@ -24,9 +25,9 @@ import scala.collection.generic._
*/
@cloneable
trait Buffer[A] extends Sequence[A]
- with TraversableClass[A, Buffer]
- with BufferTemplate[A, Buffer[A]] {
- override def companion: Companion[Buffer] = Buffer
+ with GenericTraversableTemplate[A, Buffer]
+ with BufferLike[A, Buffer[A]] {
+ override def companion: GenericCompanion[Buffer] = Buffer
}
/** Factory object for <code>Buffer</code> trait.
diff --git a/src/library/scala/collection/generic/BufferTemplate.scala b/src/library/scala/collection/mutable/BufferLike.scala
index f1899e480f..a2ac8ed354 100644
--- a/src/library/scala/collection/generic/BufferTemplate.scala
+++ b/src/library/scala/collection/mutable/BufferLike.scala
@@ -9,11 +9,11 @@
// $Id$
-package scala.collection.generic
+package scala.collection
+package mutable
-import scala.collection._
-import scala.collection.mutable.Buffer
-import scala.collection.script._
+import generic._
+import script._
/** Buffers are used to create sequences of elements incrementally by
* appending, prepending, or inserting new elements. It is also
@@ -25,17 +25,17 @@ import scala.collection.script._
* @version 2.8
*/
@cloneable
-trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
+trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]]
extends Growable[A]
with Shrinkable[A]
with Scriptable[A]
with Addable[A, This]
with Subtractable[A, This]
with Cloneable[This]
- with SequenceTemplate[A, This]
+ with SequenceLike[A, This]
{ self =>
- import collection.{Iterable, Traversable}
+ import scala.collection.{Iterable, Traversable}
// Abstract methods from Vector:
@@ -57,7 +57,7 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
*/
def length: Int
-// Abstract methods from Appendable
+// Abstract methods from Appendabl
/** Append a single element to this buffer.
*
@@ -328,7 +328,7 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
repr
}
- def readOnly: collection.Sequence[A] = toSequence
+ def readOnly: scala.collection.Sequence[A] = toSequence
}
diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala
index 0fb86f8ee5..3b60076cb6 100644
--- a/src/library/scala/collection/mutable/BufferProxy.scala
+++ b/src/library/scala/collection/mutable/BufferProxy.scala
@@ -9,10 +9,11 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
-import scala.collection.script._
+import generic._
+import script._
/** This is a simple proxy class for <a href="Buffer.html"
* target="contentFrame"><code>scala.collection.mutable.Buffer</code></a>.
@@ -55,14 +56,14 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
* @param iter the iterable object.
* @return the updated buffer.
*/
- def ++(iter: collection.Iterable[A]): Buffer[A] = self.++(iter)
+ def ++(iter: scala.collection.Iterable[A]): Buffer[A] = self.++(iter)
/** Appends a number of elements provided by an iterable object
* via its <code>iterator</code> method.
*
* @param iter the iterable object.
*/
- def ++=(iter: collection.Iterable[A]): this.type = { self.++=(iter); this }
+ def ++=(iter: scala.collection.Iterable[A]): this.type = { self.++=(iter); this }
/** Appends a sequence of elements to this buffer.
*
@@ -75,7 +76,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
*
* @param iter the iterable object.
*/
- def appendAll(iter: collection.Iterable[A]) { self.appendAll(iter) }
+ def appendAll(iter: scala.collection.Iterable[A]) { self.appendAll(iter) }
/** Prepend a single element to this buffer and return
* the identity of the buffer.
@@ -90,7 +91,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
*
* @param iter the iterable object.
*/
- def ++:(iter: collection.Iterable[A]): Buffer[A] = self.++:(iter)
+ def ++:(iter: scala.collection.Iterable[A]): Buffer[A] = self.++:(iter)
/** Prepend an element to this list.
*
@@ -104,7 +105,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
*
* @param iter the iterable object.
*/
- def prependAll(elems: collection.Iterable[A]) { self.prependAll(elems) }
+ def prependAll(elems: scala.collection.Iterable[A]) { self.prependAll(elems) }
/** Inserts new elements at the index <code>n</code>. Opposed to method
* <code>update</code>, this method will not replace an element with a
@@ -122,9 +123,9 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
* @param n the index where a new element will be inserted.
* @param iter the iterable object providing all elements to insert.
*/
- def insertAll(n: Int, iter: collection.Iterable[A]): Unit = self.insertAll(n, iter)
+ def insertAll(n: Int, iter: scala.collection.Iterable[A]): Unit = self.insertAll(n, iter)
- override def insertAll(n: Int, iter: collection.Traversable[A]): Unit = self.insertAll(n, iter)
+ override def insertAll(n: Int, iter: scala.collection.Traversable[A]): Unit = self.insertAll(n, iter)
/** Replace element at index <code>n</code> with the new element
* <code>newelem</code>.
diff --git a/src/library/scala/collection/generic/Builder.scala b/src/library/scala/collection/mutable/Builder.scala
index 3d0489223c..6c292380fd 100644
--- a/src/library/scala/collection/generic/Builder.scala
+++ b/src/library/scala/collection/mutable/Builder.scala
@@ -8,8 +8,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
+
+import generic._
/** The base trait of all builders.
* A builder lets one construct a collection incrementally, by adding
@@ -47,7 +49,7 @@ trait Builder[-Elem, +To] extends Growable[Elem] {
def +=(x: Elem): this.type = { self += x; this }
def clear() = self.clear()
override def ++=(xs: Iterator[Elem]): this.type = { self ++= xs; this }
- override def ++=(xs: Traversable[Elem]): this.type = { self ++= xs; this }
+ override def ++=(xs:scala.collection.Traversable[Elem]): this.type = { self ++= xs; this }
def result: NewTo = f(self.result)
}
}
diff --git a/src/library/scala/collection/generic/Cloneable.scala b/src/library/scala/collection/mutable/Cloneable.scala
index 667a7af588..bcd9312ace 100644
--- a/src/library/scala/collection/generic/Cloneable.scala
+++ b/src/library/scala/collection/mutable/Cloneable.scala
@@ -9,8 +9,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
/** A trait for cloneable collections.
*/
diff --git a/src/library/scala/collection/mutable/CloneableCollection.scala b/src/library/scala/collection/mutable/CloneableCollection.scala
index 40ee9f8649..1fe3692530 100644
--- a/src/library/scala/collection/mutable/CloneableCollection.scala
+++ b/src/library/scala/collection/mutable/CloneableCollection.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** The J2ME version of the library defined this trait with a <code>clone</code>
* method to substitute for the lack of <code>Object.clone</code> there.
diff --git a/src/library/scala/collection/mutable/DefaultEntry.scala b/src/library/scala/collection/mutable/DefaultEntry.scala
index 16a4448650..7c6633f1a5 100644
--- a/src/library/scala/collection/mutable/DefaultEntry.scala
+++ b/src/library/scala/collection/mutable/DefaultEntry.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
@serializable
final class DefaultEntry[A, B](val key: A, var value: B)
diff --git a/src/library/scala/collection/mutable/DefaultMapModel.scala b/src/library/scala/collection/mutable/DefaultMapModel.scala
index 0f18ea0986..d5719a4b6a 100644
--- a/src/library/scala/collection/mutable/DefaultMapModel.scala
+++ b/src/library/scala/collection/mutable/DefaultMapModel.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This class is used internally. It implements the mutable <code>Map</code>
* class in terms of three functions: <code>findEntry</code>,
diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala
index 6471f4ba3c..d17ed638de 100644
--- a/src/library/scala/collection/mutable/DoubleLinkedList.scala
+++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** This class implements single linked lists where both the head (<code>elem</code>)
* and the tail (<code>next</code>) are mutable.
@@ -22,11 +23,11 @@ import scala.collection.generic._
*/
@serializable @SerialVersionUID(419155950203746706L)
class DoubleLinkedList[A](_elem: A, _next: DoubleLinkedList[A]) extends LinearSequence[A]
- with TraversableClass[A, DoubleLinkedList]
- with DoubleLinkedListTemplate[A, DoubleLinkedList[A]] {
+ with GenericTraversableTemplate[A, DoubleLinkedList]
+ with DoubleLinkedListLike[A, DoubleLinkedList[A]] {
elem = _elem
next = _next
- override def companion: Companion[DoubleLinkedList] = DoubleLinkedList
+ override def companion: GenericCompanion[DoubleLinkedList] = DoubleLinkedList
}
object DoubleLinkedList extends SequenceFactory[DoubleLinkedList] {
diff --git a/src/library/scala/collection/generic/DoubleLinkedListTemplate.scala b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala
index 082cce4eae..637d67396b 100644
--- a/src/library/scala/collection/generic/DoubleLinkedListTemplate.scala
+++ b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala
@@ -9,8 +9,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
/** This extensible class may be used as a basis for implementing double
* linked lists. Type variable <code>A</code> refers to the element type
@@ -20,7 +20,7 @@ import scala.collection._
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-trait DoubleLinkedListTemplate[A, This >: Null <: LinearSequence[A] with DoubleLinkedListTemplate[A, This]] extends LinkedListTemplate[A, This] { self =>
+trait DoubleLinkedListLike[A, This >: Null <: LinearSequence[A] with DoubleLinkedListLike[A, This]] extends LinkedListLike[A, This] { self =>
var prev: This = _
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala
index 7d360fd9bc..824d7b4326 100644
--- a/src/library/scala/collection/mutable/FlatHashTable.scala
+++ b/src/library/scala/collection/mutable/FlatHashTable.scala
@@ -8,7 +8,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
import Predef._
diff --git a/src/library/scala/collection/mutable/GenericArray.scala b/src/library/scala/collection/mutable/GenericArray.scala
index 08372f6664..ef8ea6a870 100644
--- a/src/library/scala/collection/mutable/GenericArray.scala
+++ b/src/library/scala/collection/mutable/GenericArray.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** This class is used internally to implement data structures that
* are based on resizable arrays.
@@ -22,10 +23,10 @@ import scala.collection.generic._
*/
class GenericArray[A](override val length: Int)
extends Vector[A]
- with TraversableClass[A, GenericArray]
- with VectorTemplate[A, GenericArray[A]] {
+ with GenericTraversableTemplate[A, GenericArray]
+ with VectorLike[A, GenericArray[A]] {
- override def companion: Companion[GenericArray] = GenericArray
+ override def companion: GenericCompanion[GenericArray] = GenericArray
val array: Array[AnyRef] = new Array[AnyRef](length)
diff --git a/src/library/scala/collection/mutable/HashEntry.scala b/src/library/scala/collection/mutable/HashEntry.scala
index 01cd59f8d8..a2488da3c7 100644
--- a/src/library/scala/collection/mutable/HashEntry.scala
+++ b/src/library/scala/collection/mutable/HashEntry.scala
@@ -5,7 +5,8 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-package scala.collection.mutable
+package scala.collection
+package mutable
trait HashEntry [A, E] {
val key: A
diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala
index f3e02cd0e8..5638e13af8 100644
--- a/src/library/scala/collection/mutable/HashMap.scala
+++ b/src/library/scala/collection/mutable/HashMap.scala
@@ -9,13 +9,14 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
@serializable @SerialVersionUID(-8682987922734091219L)
class HashMap[A, B] extends Map[A, B]
- with MutableMapTemplate[A, B, HashMap[A, B]]
+ with MapLike[A, B, HashMap[A, B]]
with HashTable[A] {
override def empty: HashMap[A, B] = HashMap.empty[A, B]
diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala
index b150c75773..3f20d0f6cb 100644
--- a/src/library/scala/collection/mutable/HashSet.scala
+++ b/src/library/scala/collection/mutable/HashSet.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** This class implements mutable sets using a hashtable.
*
@@ -21,10 +22,10 @@ import scala.collection.generic._
*/
@serializable
class HashSet[A] extends Set[A]
- with SetClass[A, HashSet]
- with MutableSetTemplate[A, HashSet[A]]
+ with GenericSetTemplate[A, HashSet]
+ with SetLike[A, HashSet[A]]
with FlatHashTable[A] {
- override def companion: Companion[HashSet] = HashSet
+ override def companion: GenericCompanion[HashSet] = HashSet
override def size = super.size
diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala
index 77211f41b4..d8cc3bd828 100644
--- a/src/library/scala/collection/mutable/HashTable.scala
+++ b/src/library/scala/collection/mutable/HashTable.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This class can be used to construct data structures that are based
* on hashtables. Class <code>HashTable[A]</code> implements a hashtable
@@ -28,7 +29,7 @@ package scala.collection.mutable
* @author Martin Odersky
* @version 2.0, 31/12/2006
*/
-trait HashTable[A] extends AnyRef {
+trait HashTable[A] {
protected type Entry >: Null <: HashEntry[A, Entry]
diff --git a/src/library/scala/collection/mutable/History.scala b/src/library/scala/collection/mutable/History.scala
index 1e96b7accd..3fa6f7b37f 100644
--- a/src/library/scala/collection/mutable/History.scala
+++ b/src/library/scala/collection/mutable/History.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** <code>History[A, B]</code> objects may subscribe to events of
diff --git a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
index c309ce643e..3856a4a6e9 100644
--- a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
+++ b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
@@ -40,14 +40,14 @@ extends Map[A, B]
override def isDefinedAt(key: A) = imap.isDefinedAt(key)
- override def keySet: collection.Set[A] = imap.keySet
+ override def keySet: scala.collection.Set[A] = imap.keySet
override def keysIterator: Iterator[A] = imap.keysIterator
@deprecated("use `keysIterator' instead")
override def keys: Iterator[A] = imap.keysIterator
- override def valueIterable: collection.Iterable[B] = imap.valueIterable
+ override def valueIterable: scala.collection.Iterable[B] = imap.valueIterable
override def valuesIterator: Iterator[B] = imap.valuesIterator
diff --git a/src/library/scala/collection/mutable/Iterable.scala b/src/library/scala/collection/mutable/Iterable.scala
index 2a8c4eb773..c9df8627ca 100644
--- a/src/library/scala/collection/mutable/Iterable.scala
+++ b/src/library/scala/collection/mutable/Iterable.scala
@@ -5,9 +5,10 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** <p>
* A subtrait of <a href="../Iterable.html" target="contentFrame">
@@ -19,10 +20,10 @@ import scala.collection.generic._
* @version 2.8
*/
trait Iterable[A] extends Traversable[A]
- with collection.Iterable[A]
- with TraversableClass[A, Iterable]
- with IterableTemplate[A, Iterable[A]] {
- override def companion: Companion[Iterable] = Iterable
+ with scala.collection.Iterable[A]
+ with GenericTraversableTemplate[A, Iterable]
+ with IterableLike[A, Iterable[A]] {
+ override def companion: GenericCompanion[Iterable] = Iterable
}
/** <p>
diff --git a/src/library/scala/collection/generic/LazyBuilder.scala b/src/library/scala/collection/mutable/LazyBuilder.scala
index 3f444bc02e..7ddcb4a1f1 100644
--- a/src/library/scala/collection/generic/LazyBuilder.scala
+++ b/src/library/scala/collection/mutable/LazyBuilder.scala
@@ -8,21 +8,18 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
-
-// import immutable.{List, Nil, ::}
-import mutable.ListBuffer
+package scala.collection
+package mutable
/** A builder that constructs its result lazily. Iterators or iterables to
* be added to this builder with `++=` are not evaluated until `result` is called.
*/
abstract class LazyBuilder[Elem, +To] extends Builder[Elem, To] {
/** The different segments of elements to be added to the builder, represented as iterators */
- protected var parts = new ListBuffer[Traversable[Elem]]
+ protected var parts = new ListBuffer[scala.collection.Traversable[Elem]]
def +=(x: Elem): this.type = { parts += List(x); this }
override def ++=(xs: Iterator[Elem]): this.type = { parts += xs.toStream; this }
- override def ++=(xs: Traversable[Elem]): this.type = { parts += xs; this }
+ override def ++=(xs: scala.collection.Traversable[Elem]): this.type = { parts += xs; this }
def result(): To
def clear() { parts.clear() }
}
diff --git a/src/library/scala/collection/mutable/LinearSequence.scala b/src/library/scala/collection/mutable/LinearSequence.scala
index 7f57ede9e0..c11893020b 100644
--- a/src/library/scala/collection/mutable/LinearSequence.scala
+++ b/src/library/scala/collection/mutable/LinearSequence.scala
@@ -9,18 +9,19 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** A subtrait of <code>collection.Sequence</code> which represents sequences
* that cannot be mutated.
*/
trait LinearSequence[A] extends Sequence[A]
- with collection.LinearSequence[A]
- with TraversableClass[A, LinearSequence]
- with LinearSequenceTemplate[A, LinearSequence[A]] {
- override def companion: Companion[LinearSequence] = LinearSequence
+ with scala.collection.LinearSequence[A]
+ with GenericTraversableTemplate[A, LinearSequence]
+ with LinearSequenceLike[A, LinearSequence[A]] {
+ override def companion: GenericCompanion[LinearSequence] = LinearSequence
}
object LinearSequence extends SequenceFactory[LinearSequence] {
diff --git a/src/library/scala/collection/mutable/LinkedEntry.scala b/src/library/scala/collection/mutable/LinkedEntry.scala
index b46b5cdbe7..6170de627b 100644
--- a/src/library/scala/collection/mutable/LinkedEntry.scala
+++ b/src/library/scala/collection/mutable/LinkedEntry.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
@serializable
final class LinkedEntry[A, B](val key: A, var value: B)
diff --git a/src/library/scala/collection/mutable/LinkedHashMap.scala b/src/library/scala/collection/mutable/LinkedHashMap.scala
index 84a74b25c1..193850c405 100644
--- a/src/library/scala/collection/mutable/LinkedHashMap.scala
+++ b/src/library/scala/collection/mutable/LinkedHashMap.scala
@@ -9,10 +9,11 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
+import generic._
import Predef._
-import scala.collection.generic._
/** This class implements mutable maps using a hashtable.
*
@@ -27,7 +28,7 @@ object LinkedHashMap extends MutableMapFactory[LinkedHashMap] {
@serializable
class LinkedHashMap[A, B] extends Map[A, B]
- with MutableMapTemplate[A, B, LinkedHashMap[A, B]]
+ with MapLike[A, B, LinkedHashMap[A, B]]
with HashTable[A] {
override def empty = LinkedHashMap.empty[A, B]
diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala
index d746f834b5..4ec6a80108 100644
--- a/src/library/scala/collection/mutable/LinkedHashSet.scala
+++ b/src/library/scala/collection/mutable/LinkedHashSet.scala
@@ -8,20 +8,21 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** Todo: this has O(n) cost for element removal.
* Should be rewritten to be more efficient.
*/
@serializable
class LinkedHashSet[A] extends Set[A]
- with SetClass[A, LinkedHashSet]
- with MutableSetTemplate[A, LinkedHashSet[A]]
+ with GenericSetTemplate[A, LinkedHashSet]
+ with SetLike[A, LinkedHashSet[A]]
with FlatHashTable[A]
{
- override def companion: Companion[LinkedHashSet] = LinkedHashSet
+ override def companion: GenericCompanion[LinkedHashSet] = LinkedHashSet
protected val ordered = new ListBuffer[A]
diff --git a/src/library/scala/collection/mutable/LinkedList.scala b/src/library/scala/collection/mutable/LinkedList.scala
index 25cde0e993..4fc11919a4 100644
--- a/src/library/scala/collection/mutable/LinkedList.scala
+++ b/src/library/scala/collection/mutable/LinkedList.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** This class implements single linked lists where both the head (<code>elem</code>)
* and the tail (<code>next</code>) are mutable.
@@ -22,11 +23,11 @@ import scala.collection.generic._
*/
@serializable
class LinkedList[A](_elem: A, _next: LinkedList[A]) extends LinearSequence[A]
- with TraversableClass[A, LinkedList]
- with LinkedListTemplate[A, LinkedList[A]] {
+ with GenericTraversableTemplate[A, LinkedList]
+ with LinkedListLike[A, LinkedList[A]] {
elem = _elem
next = _next
- override def companion: Companion[LinkedList] = LinkedList
+ override def companion: GenericCompanion[LinkedList] = LinkedList
}
object LinkedList extends SequenceFactory[LinkedList] {
diff --git a/src/library/scala/collection/generic/LinkedListTemplate.scala b/src/library/scala/collection/mutable/LinkedListLike.scala
index b15e5c50d0..5e706b5e62 100644
--- a/src/library/scala/collection/generic/LinkedListTemplate.scala
+++ b/src/library/scala/collection/mutable/LinkedListLike.scala
@@ -9,8 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
+
+import generic._
import annotation.tailrec
/** This extensible class may be used as a basis for implementing linked
@@ -21,7 +23,7 @@ import annotation.tailrec
* @author Martin Odersky
* @version 2.8
*/
-trait LinkedListTemplate[A, This >: Null <: Sequence[A] with LinkedListTemplate[A, This]] extends SequenceTemplate[A, This] { self =>
+trait LinkedListLike[A, This >: Null <: Sequence[A] with LinkedListLike[A, This]] extends SequenceLike[A, This] { self =>
var elem: A = _
var next: This = _
diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala
index 30b113f3be..470936bd82 100644
--- a/src/library/scala/collection/mutable/ListBuffer.scala
+++ b/src/library/scala/collection/mutable/ListBuffer.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
-import scala.collection.immutable
+import generic._
/** A Buffer implementation back up by a list. It provides constant time
* prepend and append. Most other operations are linear.
@@ -24,14 +24,14 @@ import scala.collection.immutable
@serializable @SerialVersionUID(3419063961353022661L)
final class ListBuffer[A]
extends Buffer[A]
- with TraversableClass[A, ListBuffer]
- with BufferTemplate[A, ListBuffer[A]]
+ with GenericTraversableTemplate[A, ListBuffer]
+ with BufferLike[A, ListBuffer[A]]
with Builder[A, List[A]]
with SequenceForwarder[A]
{
- override def companion: Companion[ListBuffer] = ListBuffer
+ override def companion: GenericCompanion[ListBuffer] = ListBuffer
- import collection.Traversable
+ import scala.collection.Traversable
private var start: List[A] = Nil
private var last0: ::[A] = _
diff --git a/src/library/scala/collection/mutable/ListMap.scala b/src/library/scala/collection/mutable/ListMap.scala
index 9bdf5bd341..c80a265896 100644
--- a/src/library/scala/collection/mutable/ListMap.scala
+++ b/src/library/scala/collection/mutable/ListMap.scala
@@ -9,12 +9,13 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
@serializable
-class ListMap[A, B] extends Map[A, B] with MutableMapTemplate[A, B, ListMap[A, B]] {
+class ListMap[A, B] extends Map[A, B] with MapLike[A, B, ListMap[A, B]] {
override def empty = ListMap.empty[A, B]
diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala
index c59211fc96..87ff3efa73 100644
--- a/src/library/scala/collection/mutable/Map.scala
+++ b/src/library/scala/collection/mutable/Map.scala
@@ -9,20 +9,20 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
trait Map[A, B]
extends Iterable[(A, B)]
- with collection.Map[A, B]
- with MutableMapTemplate[A, B, Map[A, B]]
- with Unhashable {
+ with scala.collection.Map[A, B]
+ with MapLike[A, B, Map[A, B]] {
override def empty: Map[A, B] = Map.empty
/** Return a read-only projection of this map. !!! or just use an (immutable) MapProxy?
- def readOnly : collection.Map[A, B] = new collection.Map[A, B] {
+ def readOnly : scala.collection.Map[A, B] = new scala.collection.Map[A, B] {
override def size = self.size
override def update(key: A, value: B) = self.update(key, value)
override def - (elem: A) = self - elem
diff --git a/src/library/scala/collection/generic/MapBuilder.scala b/src/library/scala/collection/mutable/MapBuilder.scala
index 90c667a50a..bcbd50c44e 100644
--- a/src/library/scala/collection/generic/MapBuilder.scala
+++ b/src/library/scala/collection/mutable/MapBuilder.scala
@@ -8,17 +8,15 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
-
-// import collection.immutable.{List, Nil, ::}
+package scala.collection
+package mutable
/** The canonical builder for immutable maps, working with the map's `+` method
* to add new elements.
* Collections are built from their `empty` element using this + method.
* @param empty The empty element of the collection.
*/
-class MapBuilder[A, B, Coll <: Map[A, B] with MapTemplate[A, B, Coll]](empty: Coll)
+class MapBuilder[A, B, Coll <: scala.collection.Map[A, B] with scala.collection.MapLike[A, B, Coll]](empty: Coll)
extends Builder[(A, B), Coll] {
protected var elems: Coll = empty
def +=(x: (A, B)): this.type = {
diff --git a/src/library/scala/collection/generic/MutableMapTemplate.scala b/src/library/scala/collection/mutable/MapLike.scala
index 1a575a16e7..3e72d23ba3 100644
--- a/src/library/scala/collection/generic/MutableMapTemplate.scala
+++ b/src/library/scala/collection/mutable/MapLike.scala
@@ -9,8 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
+
+import generic._
/** <p>
* A generic template for mutable maps from keys of type <code>A</code> to
@@ -40,20 +42,22 @@ import scala.collection._
* <code>size</code> for efficiency.
* </p>
*/
-trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with mutable.Map[A, B]]
- extends MutableMapTemplateBase[A, B, This]
+trait MapLike[A, B, +This <: MapLike[A, B, This] with Map[A, B]]
+ extends MapLikeBase[A, B, This]
with Builder[(A, B), This]
with Growable[(A, B)]
with Shrinkable[A]
with Cloneable[This]
{ self =>
+ import scala.collection.Traversable
+
/** <p>
* A common implementation of <code>newBuilder</code> for all mutable maps
* in terms of <code>empty</code>.
* </p>
* <p>
- * Overrides <code>MapTemplate</code> implementation for better efficiency.
+ * Overrides <code>MapLike</code> implementation for better efficiency.
* </p>
*/
override protected[this] def newBuilder: Builder[(A, B), This] = empty
diff --git a/src/library/scala/collection/generic/MutableMapTemplateBase.scala b/src/library/scala/collection/mutable/MapLikeBase.scala
index e55a04e1a1..02b4e5047a 100644
--- a/src/library/scala/collection/generic/MutableMapTemplateBase.scala
+++ b/src/library/scala/collection/mutable/MapLikeBase.scala
@@ -9,8 +9,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
/** The reason for this class is so that we can
* have both a generic immutable `+` with signature
@@ -25,12 +25,12 @@ import scala.collection._
* The latter is required for backwards compatibility.
* We can't have both methods in the same class, as that would give a double definition.
* They are OK in different classes though, and narrowly escape a `same erasure' problem.
- * Once the deprecated + goes away we can do without class MutableMapTemplateBase.
+ * Once the deprecated + goes away we can do without class MapLikeBase.
*
* @author Martin Odersky
* @version 2.8
*/
-trait MutableMapTemplateBase[A, B, +This <: MutableMapTemplateBase[A, B, This] with mutable.Map[A, B]]
- extends MapTemplate[A, B, This] with Cloneable[This] {
+trait MapLikeBase[A, B, +This <: MapLikeBase[A, B, This] with Map[A, B]]
+ extends scala.collection.MapLike[A, B, This] with Cloneable[This] {
def + [B1 >: B] (kv: (A, B1)): mutable.Map[A, B1] = clone().asInstanceOf[mutable.Map[A, B1]] += kv
}
diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala
index 4092348f1a..2b99ccc0be 100644
--- a/src/library/scala/collection/mutable/MapProxy.scala
+++ b/src/library/scala/collection/mutable/MapProxy.scala
@@ -9,9 +9,8 @@
// $Id$
-package scala.collection.mutable
-
-import scala.collection.generic.MapProxyTemplate
+package scala.collection
+package mutable
/** <p>
* This is a simple wrapper class for <a href="Map.html"
@@ -26,7 +25,7 @@ import scala.collection.generic.MapProxyTemplate
* @version 2.0, 31/12/2006
*/
-trait MapProxy[A, B] extends Map[A, B] with MapProxyTemplate[A, B, Map[A, B]]
+trait MapProxy[A, B] extends Map[A, B] with MapProxyLike[A, B, Map[A, B]]
{
override def repr = this
override def empty: MapProxy[A, B] = new MapProxy[A, B] { val self = MapProxy.this.self.empty }
diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala
index 7f7a8e9b07..488095770d 100644
--- a/src/library/scala/collection/mutable/MultiMap.scala
+++ b/src/library/scala/collection/mutable/MultiMap.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This class is typically used as a mixin. It turns maps which map <code>A</code>
diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala
index 28b6ccbd5a..f6b8182d71 100644
--- a/src/library/scala/collection/mutable/MutableList.scala
+++ b/src/library/scala/collection/mutable/MutableList.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** <p>
* This class is used internally to represent mutable lists. It is the
@@ -26,7 +27,7 @@ import scala.collection.generic._
*/
@serializable @SerialVersionUID(5938451523372603072L)
class MutableList[A] extends LinearSequence[A]
- with LinearSequenceTemplate[A, MutableList[A]]
+ with LinearSequenceLike[A, MutableList[A]]
with Builder[A, MutableList[A]] {
override protected[this] def newBuilder = new MutableList[A]
diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala
index 59f1fad220..3f01b62786 100644
--- a/src/library/scala/collection/mutable/ObservableBuffer.scala
+++ b/src/library/scala/collection/mutable/ObservableBuffer.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.script._
+import script._
/** This class is typically used as a mixin. It adds a subscription
* mechanism to the <code>Buffer</code> class into which this abstract
diff --git a/src/library/scala/collection/mutable/ObservableMap.scala b/src/library/scala/collection/mutable/ObservableMap.scala
index c43fd8ab9b..5cfb232bf0 100644
--- a/src/library/scala/collection/mutable/ObservableMap.scala
+++ b/src/library/scala/collection/mutable/ObservableMap.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.script._
+import script._
/** This class is typically used as a mixin. It adds a subscription
diff --git a/src/library/scala/collection/mutable/ObservableSet.scala b/src/library/scala/collection/mutable/ObservableSet.scala
index d01d8803da..9a688c779f 100644
--- a/src/library/scala/collection/mutable/ObservableSet.scala
+++ b/src/library/scala/collection/mutable/ObservableSet.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.script._
+import script._
/** This class is typically used as a mixin. It adds a subscription
* mechanism to the <code>Set</code> class into which this abstract
diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala
index ab5e897ca3..b1b5d320d4 100644
--- a/src/library/scala/collection/mutable/OpenHashMap.scala
+++ b/src/library/scala/collection/mutable/OpenHashMap.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection
+package mutable
object OpenHashMap{
def apply[K, V](elems : (K, V)*) = {
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala
index cb471a0ee1..3936045fa3 100644
--- a/src/library/scala/collection/mutable/PriorityQueue.scala
+++ b/src/library/scala/collection/mutable/PriorityQueue.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic.{ Addable, Cloneable, Growable }
+import generic.{ Addable, Growable }
/** This class implements priority queues using a heap.
@@ -102,7 +103,7 @@ class PriorityQueue[A](implicit ord: Ordering[A])
*
* @param iter an iterable object
*/
- def ++(elems: Traversable[A]) = { this.clone() ++= elems } // ??? XXX why does this "override nothing" with override?
+ override def ++(elems: scala.collection.Traversable[A]) = { this.clone() ++= elems } // ??? XXX why does this "override nothing" with override?
/** Adds all elements provided by an iterator into the priority queue.
*
diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
index e673732ff0..42249e7991 100644
--- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala
+++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
@@ -8,7 +8,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This class implements priority queues using a heap. The
* elements of the queue have to be ordered in terms of the
@@ -51,7 +52,7 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority
*
* @param iter an iterable object
*/
- def ++=(iter: collection.Iterable[A]): this.type = {
+ def ++=(iter: scala.collection.Iterable[A]): this.type = {
self ++= iter
this
}
diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala
index 60b1e185dc..4918cda3a5 100644
--- a/src/library/scala/collection/mutable/Publisher.scala
+++ b/src/library/scala/collection/mutable/Publisher.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** <code>Publisher[A,This]</code> objects publish events of type <code>A</code>
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index f58a231364..a9b1ec88ea 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** <code>Queue</code> objects implement data structures that allow to
* insert and retrieve elements in a first-in-first-out (FIFO) manner.
diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala
index 3f88fc5b58..ecacda9373 100644
--- a/src/library/scala/collection/mutable/QueueProxy.scala
+++ b/src/library/scala/collection/mutable/QueueProxy.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** <code>Queue</code> objects implement data structures that allow to
* insert and retrieve elements in a first-in-first-out (FIFO) manner.
@@ -49,7 +50,7 @@ trait QueueProxy[A] extends Queue[A] with Proxy {
*
* @param iter an iterable object
*/
- def ++=(iter: collection.Iterable[A]): this.type = {
+ def ++=(iter: scala.collection.Iterable[A]): this.type = {
self ++= iter
this
}
diff --git a/src/library/scala/collection/mutable/ResizableArray.scala b/src/library/scala/collection/mutable/ResizableArray.scala
index e0fbbf8e79..7b69d96894 100644
--- a/src/library/scala/collection/mutable/ResizableArray.scala
+++ b/src/library/scala/collection/mutable/ResizableArray.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** This class is used internally to implement data structures that
* are based on resizable arrays.
@@ -21,10 +22,10 @@ import scala.collection.generic._
* @version 2.8
*/
trait ResizableArray[A] extends Vector[A]
- with TraversableClass[A, ResizableArray]
- with VectorTemplate[A, ResizableArray[A]] {
+ with GenericTraversableTemplate[A, ResizableArray]
+ with VectorLike[A, ResizableArray[A]] {
- override def companion: Companion[ResizableArray] = ResizableArray
+ override def companion: GenericCompanion[ResizableArray] = ResizableArray
protected def initialSize: Int = 16
protected var array: Array[AnyRef] = new Array[AnyRef](initialSize max 1)
diff --git a/src/library/scala/collection/mutable/RevertibleHistory.scala b/src/library/scala/collection/mutable/RevertibleHistory.scala
index 1ab0e2a555..77cf2bb27b 100644
--- a/src/library/scala/collection/mutable/RevertibleHistory.scala
+++ b/src/library/scala/collection/mutable/RevertibleHistory.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** A revertible history is a <code>History</code> object which supports
diff --git a/src/library/scala/collection/mutable/Sequence.scala b/src/library/scala/collection/mutable/Sequence.scala
index 2a263b0a4d..f56c9d4b3d 100644
--- a/src/library/scala/collection/mutable/Sequence.scala
+++ b/src/library/scala/collection/mutable/Sequence.scala
@@ -9,20 +9,20 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** A subtrait of <code>collection.Sequence</code> which represents sequences
* that can be mutated.
* The class adds an <code>update</code> method to <code>collection.Sequence</code>.
*/
trait Sequence[A] extends Iterable[A]
- with collection.Sequence[A]
- with TraversableClass[A, Sequence]
- with SequenceTemplate[A, Sequence[A]]
- with Unhashable {
- override def companion: Companion[Sequence] = Sequence
+ with scala.collection.Sequence[A]
+ with GenericTraversableTemplate[A, Sequence]
+ with SequenceLike[A, Sequence[A]] {
+ override def companion: GenericCompanion[Sequence] = Sequence
def update(idx: Int, elem: A)
}
diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala
index 55c3d3f1aa..9f24945153 100644
--- a/src/library/scala/collection/mutable/Set.scala
+++ b/src/library/scala/collection/mutable/Set.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** A generic trait for mutable sets. Concrete set implementations
* have to provide functionality for the abstract methods in Set:
@@ -26,11 +27,10 @@ import scala.collection.generic._
* @version 2.8
*/
trait Set[A] extends Iterable[A]
- with collection.Set[A]
- with SetClass[A, Set]
- with MutableSetTemplate[A, Set[A]]
- with Unhashable {
- override def companion: Companion[Set] = Set
+ with scala.collection.Set[A]
+ with GenericSetTemplate[A, Set]
+ with SetLike[A, Set[A]] {
+ override def companion: GenericCompanion[Set] = Set
}
/** The canonical factory methods for <a href="Set.html">mutable sets</a>.
diff --git a/src/library/scala/collection/generic/SetBuilder.scala b/src/library/scala/collection/mutable/SetBuilder.scala
index df8949e93c..0687dbc35d 100644
--- a/src/library/scala/collection/generic/SetBuilder.scala
+++ b/src/library/scala/collection/mutable/SetBuilder.scala
@@ -8,17 +8,17 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
-// import collection.immutable.{List, Nil, ::}
+import generic._
/** The canonical builder for collections that are addable, i.e. that support
* an efficient + method which adds an element to the collection.
* Collections are built from their empty element using this + method.
* @param empty The empty element of the collection.
*/
-class SetBuilder[A, Coll <: Addable[A, Coll] with Iterable[A] with IterableTemplate[A, Coll]](empty: Coll)
+class SetBuilder[A, Coll <: Addable[A, Coll] with scala.collection.Iterable[A] with scala.collection.IterableLike[A, Coll]](empty: Coll)
extends Builder[A, Coll] {
protected var elems: Coll = empty
def +=(x: A): this.type = { elems = elems + x; this }
diff --git a/src/library/scala/collection/generic/MutableSetTemplate.scala b/src/library/scala/collection/mutable/SetLike.scala
index 7a1aa9c974..fb36212d21 100644
--- a/src/library/scala/collection/generic/MutableSetTemplate.scala
+++ b/src/library/scala/collection/mutable/SetLike.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
+import generic._
import script._
/** <p>
@@ -35,8 +36,8 @@ import script._
* </p>
*
*/
-trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Set[A]]
- extends SetTemplate[A, This]
+trait SetLike[A, +This <: SetLike[A, This] with Set[A]]
+ extends scala.collection.SetLike[A, This]
with Scriptable[A]
with Builder[A, This]
with Growable[A]
@@ -45,7 +46,7 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
{ self =>
/** A common implementation of <code>newBuilder</code> for all mutable sets
- * in terms of <code>empty</code>. Overrides <code>SetTemplate</code>
+ * in terms of <code>empty</code>. Overrides <code>SetLike</code>
* implementation for better efficiency.
*/
override protected[this] def newBuilder: Builder[A, This] = empty
@@ -137,7 +138,7 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
*/
@deprecated("Use ++= instead if you intend to add by side effect to an existing collection.\n"+
"Use `clone() ++=' if you intend to create a new collection.")
- override def ++(iter: Traversable[A]): This = {
+ override def ++(iter: scala.collection.Traversable[A]): This = {
for (elem <- iter) +=(elem)
repr
}
@@ -185,7 +186,7 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
*/
@deprecated("Use --= instead if you intend to remove by side effect from an existing collection.\n"+
"Use `clone() --=' if you intend to create a new collection.")
- override def --(iter: Traversable[A]): This = {
+ override def --(iter: scala.collection.Traversable[A]): This = {
for (elem <- iter) -=(elem)
repr
}
diff --git a/src/library/scala/collection/mutable/SetProxy.scala b/src/library/scala/collection/mutable/SetProxy.scala
index d14cbeeb4c..b035d134b8 100644
--- a/src/library/scala/collection/mutable/SetProxy.scala
+++ b/src/library/scala/collection/mutable/SetProxy.scala
@@ -8,9 +8,8 @@
// $Id$
-package scala.collection.mutable
-
-import scala.collection.generic.SetProxyTemplate
+package scala.collection
+package mutable
/** This is a simple wrapper class for <a href="Set.html"
* target="contentFrame"><code>scala.collection.mutable.Set</code></a>.
@@ -20,7 +19,7 @@ import scala.collection.generic.SetProxyTemplate
* @author Matthias Zenger
* @version 1.1, 09/05/2004
*/
-trait SetProxy[A] extends Set[A] with SetProxyTemplate[A, Set[A]]
+trait SetProxy[A] extends Set[A] with SetProxyLike[A, Set[A]]
{
override def repr = this
override def empty = new SetProxy[A] { val self = SetProxy.this.self.empty }
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index 30caec89be..65bdae6780 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** A stack implements a data structure which allows to store and retrieve
* objects in a last-in-first-out (LIFO) fashion.
@@ -21,7 +22,7 @@ import scala.collection.generic._
* @version 2.8
*/
@serializable @cloneable
-class Stack[A] private (var elems: List[A]) extends collection.Sequence[A] with Cloneable[Stack[A]] {
+class Stack[A] private (var elems: List[A]) extends scala.collection.Sequence[A] with Cloneable[Stack[A]] {
def this() = this(Nil)
@@ -69,10 +70,10 @@ class Stack[A] private (var elems: List[A]) extends collection.Sequence[A] with
* @param elems the iterable object.
* @return the stack with the new elements on top.
*/
- def pushAll(elems: collection.Traversable[A]): this.type = { for (elem <- elems) { push(elem); () }; this }
+ def pushAll(elems: scala.collection.Traversable[A]): this.type = { for (elem <- elems) { push(elem); () }; this }
@deprecated("use pushAll") def ++=(it: Iterator[A]): this.type = pushAll(it)
- @deprecated("use pushAll") def ++=(it: collection.Iterable[A]): this.type = pushAll(it)
+ @deprecated("use pushAll") def ++=(it: scala.collection.Iterable[A]): this.type = pushAll(it)
/** Returns the top element of the stack. This method will not remove
* the element from the stack. An error is signaled if there is no
diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala
index 6161b3bc7e..27b248f982 100644
--- a/src/library/scala/collection/mutable/StackProxy.scala
+++ b/src/library/scala/collection/mutable/StackProxy.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** A stack implements a data structure which allows to store and retrieve
* objects in a last-in-first-out (LIFO) fashion.
@@ -51,7 +52,7 @@ trait StackProxy[A] extends Stack[A] with Proxy {
this
}
- override def pushAll(elems: collection.Traversable[A]): this.type = {
+ override def pushAll(elems: scala.collection.Traversable[A]): this.type = {
self pushAll elems
this
}
@@ -62,7 +63,7 @@ trait StackProxy[A] extends Stack[A] with Proxy {
*
* @param iter an iterable object
*/
- @deprecated("use pushAll") override def ++=(iter: collection.Iterable[A]): this.type = {
+ @deprecated("use pushAll") override def ++=(iter: scala.collection.Iterable[A]): this.type = {
self ++= iter
this
}
diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala
index 3d2f920dcc..1fe28e7040 100644
--- a/src/library/scala/collection/mutable/StringBuilder.scala
+++ b/src/library/scala/collection/mutable/StringBuilder.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import collection.generic._
+import generic._
import compat.Platform.arraycopy
import scala.reflect.Manifest
diff --git a/src/library/scala/collection/mutable/Subscriber.scala b/src/library/scala/collection/mutable/Subscriber.scala
index 47f7519bd7..95b212f2e8 100644
--- a/src/library/scala/collection/mutable/Subscriber.scala
+++ b/src/library/scala/collection/mutable/Subscriber.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** <code>Subscriber[A, B]</code> objects may subscribe to events of
diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala
index 4120f09acd..0f5395735f 100644
--- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala
+++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.script._
+import script._
/** This class should be used as a mixin. It synchronizes the <code>Buffer</code>
* methods of the class into which it is mixed in.
@@ -21,7 +22,7 @@ import scala.collection.script._
*/
trait SynchronizedBuffer[A] extends Buffer[A] {
- import collection.Traversable
+ import scala.collection.Traversable
abstract override def length: Int = synchronized {
super.length
diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala
index 58285ee49e..a831793cb2 100644
--- a/src/library/scala/collection/mutable/SynchronizedMap.scala
+++ b/src/library/scala/collection/mutable/SynchronizedMap.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This class should be used as a mixin. It synchronizes the <code>Map</code>
@@ -33,13 +34,13 @@ trait SynchronizedMap[A, B] extends Map[A, B] {
override def getOrElseUpdate(key: A, default: => B): B = synchronized { super.getOrElseUpdate(key, default) }
override def transform(f: (A, B) => B): this.type = synchronized[this.type] { super.transform(f) }
override def retain(p: (A, B) => Boolean): this.type = synchronized[this.type] { super.retain(p) }
- override def valueIterable: collection.Iterable[B] = synchronized { super.valueIterable }
+ override def valueIterable: scala.collection.Iterable[B] = synchronized { super.valueIterable }
@deprecated("Use `valuesIterator' instead") override def values: Iterator[B] = synchronized { super.valuesIterator }
override def valuesIterator: Iterator[B] = synchronized { super.valuesIterator }
override def clone() = synchronized { super.clone() }
override def foreach[U](f: ((A, B)) => U) = synchronized { super.foreach(f) }
override def apply(key: A): B = synchronized { super.apply(key) }
- override def keySet: collection.Set[A] = synchronized { super.keySet }
+ override def keySet: scala.collection.Set[A] = synchronized { super.keySet }
@deprecated("Use `keysIterator' instead") override def keys: Iterator[A] = synchronized { super.keysIterator }
override def keysIterator: Iterator[A] = synchronized { super.keysIterator }
override def isEmpty: Boolean = synchronized { super.isEmpty }
diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
index 937d532614..b43067766e 100644
--- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This class implements synchronized priority queues using a heap.
* The elements of the queue have to be ordered in terms of the
@@ -42,7 +43,7 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu
*
* @param iter an iterable object
*/
- def ++=(iter: collection.Iterable[A]): this.type = {
+ def ++=(iter: scala.collection.Iterable[A]): this.type = {
synchronized {
super.++=(iter)
}
diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala
index 7a803c5879..fc5d6fe20c 100644
--- a/src/library/scala/collection/mutable/SynchronizedQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This is a synchronized version of the <code>Queue[T]</code> class. It
@@ -20,7 +21,7 @@ package scala.collection.mutable
* @version 1.0, 03/05/2004
*/
class SynchronizedQueue[A] extends Queue[A] {
- import collection.Traversable
+ import scala.collection.Traversable
/** Checks if the queue is empty.
*
diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala
index 31e80c391c..8870a8b148 100644
--- a/src/library/scala/collection/mutable/SynchronizedSet.scala
+++ b/src/library/scala/collection/mutable/SynchronizedSet.scala
@@ -8,9 +8,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.script._
+import script._
/** This class should be used as a mixin. It synchronizes the <code>Set</code>
* functions of the class into which it is mixed in.
@@ -19,7 +20,7 @@ import scala.collection.script._
* @version 1.0, 08/07/2003
*/
trait SynchronizedSet[A] extends Set[A] {
- import collection.Traversable
+ import scala.collection.Traversable
abstract override def size: Int = synchronized {
super.size
@@ -69,7 +70,7 @@ trait SynchronizedSet[A] extends Set[A] {
super.remove(elem)
}
- override def intersect(that: collection.Set[A]) = synchronized {
+ override def intersect(that: scala.collection.Set[A]) = synchronized {
super.intersect(that)
}
diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala
index 740449ffe7..627c6ea913 100644
--- a/src/library/scala/collection/mutable/SynchronizedStack.scala
+++ b/src/library/scala/collection/mutable/SynchronizedStack.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** This is a synchronized version of the <code>Stack[T]</code> class. It
@@ -20,7 +21,7 @@ package scala.collection.mutable
* @version 1.0, 03/05/2004
*/
class SynchronizedStack[A] extends Stack[A] {
- import collection.Traversable
+ import scala.collection.Traversable
/** Checks if the stack is empty.
*
@@ -48,7 +49,7 @@ class SynchronizedStack[A] extends Stack[A] {
*
* @param iter an iterable object
*/
- override def pushAll(elems: collection.Traversable[A]): this.type = synchronized[this.type] { super.pushAll(elems) }
+ override def pushAll(elems: scala.collection.Traversable[A]): this.type = synchronized[this.type] { super.pushAll(elems) }
/** Pushes all elements provided by an iterator
* on top of the stack. The elements are pushed in the order they
diff --git a/src/library/scala/collection/mutable/Traversable.scala b/src/library/scala/collection/mutable/Traversable.scala
index efe06852b3..f40072ee65 100644
--- a/src/library/scala/collection/mutable/Traversable.scala
+++ b/src/library/scala/collection/mutable/Traversable.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** A subtrait of <code>collection.Traversable</code> which represents
* traversables that can be mutated.
@@ -19,11 +20,11 @@ import scala.collection.generic._
* @author Martin Odersky
* @version 2.8
*/
-trait Traversable[A] extends collection.Traversable[A]
- with TraversableClass[A, Traversable]
- with TraversableTemplate[A, Traversable[A]]
+trait Traversable[A] extends scala.collection.Traversable[A]
+ with GenericTraversableTemplate[A, Traversable]
+ with TraversableLike[A, Traversable[A]]
with Mutable {
- override def companion: Companion[Traversable] = Traversable
+ override def companion: GenericCompanion[Traversable] = Traversable
}
/** A factory object for the trait <code>Traversable</code>.
diff --git a/src/library/scala/collection/mutable/Undoable.scala b/src/library/scala/collection/mutable/Undoable.scala
index 850dcc0e6c..1257b0722e 100644
--- a/src/library/scala/collection/mutable/Undoable.scala
+++ b/src/library/scala/collection/mutable/Undoable.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
/** Classes that mix in the <code>Undoable</code> class provide an operation
diff --git a/src/library/scala/collection/mutable/Vector.scala b/src/library/scala/collection/mutable/Vector.scala
index 2b6e497731..cb81aab03b 100644
--- a/src/library/scala/collection/mutable/Vector.scala
+++ b/src/library/scala/collection/mutable/Vector.scala
@@ -9,18 +9,19 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
/** A subtrait of <code>collection.Vector</code> which represents sequences
* that can be mutated.
*/
trait Vector[A] extends Sequence[A]
- with collection.Vector[A]
- with TraversableClass[A, Vector]
- with MutableVectorTemplate[A, Vector[A]] {
- override def companion: Companion[Vector] = Vector
+ with scala.collection.Vector[A]
+ with GenericTraversableTemplate[A, Vector]
+ with VectorLike[A, Vector[A]] {
+ override def companion: GenericCompanion[Vector] = Vector
}
object Vector extends SequenceFactory[Vector] {
diff --git a/src/library/scala/collection/mutable/VectorLike.scala b/src/library/scala/collection/mutable/VectorLike.scala
index 837b7c665f..a8a505f0e3 100644
--- a/src/library/scala/collection/mutable/VectorLike.scala
+++ b/src/library/scala/collection/mutable/VectorLike.scala
@@ -13,7 +13,7 @@ package scala.collection
package mutable
import generic._
-/** A subtrait of collection.Vector which represents sequences
+/** A subtrait of scala.collection.Vector which represents sequences
* that can be mutated.
*/
trait VectorLike[A, +Repr] extends scala.collection.VectorLike[A, Repr] { self =>
@@ -25,7 +25,7 @@ trait VectorLike[A, +Repr] extends scala.collection.VectorLike[A, Repr] { self =
/** Creates a view of this iterable @see Iterable.View
*/
- override def view = new MutableVectorView[A, Repr] {
+ override def view = new VectorView[A, Repr] {
protected lazy val underlying = self.repr
override def iterator = self.iterator
override def length = self.length
diff --git a/src/library/scala/collection/generic/MutableVectorView.scala b/src/library/scala/collection/mutable/VectorView.scala
index 38c7319880..e1ec320c52 100644
--- a/src/library/scala/collection/generic/MutableVectorView.scala
+++ b/src/library/scala/collection/mutable/VectorView.scala
@@ -9,8 +9,10 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
+
+import generic._
import TraversableView.NoBuilder
@@ -19,9 +21,9 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait MutableVectorView[A, +Coll] extends MutableVectorViewTemplate[A, Coll, MutableVectorView[A, Coll]]
+trait VectorView[A, +Coll] extends VectorViewLike[A, Coll, VectorView[A, Coll]]
-object MutableVectorView {
- type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
- implicit def builderFactory[A]: BuilderFactory[A, MutableVectorView[A, mutable.Vector[_]], Coll] = new BuilderFactory[A, MutableVectorView[A, mutable.Vector[_]], Coll] { def apply(from: Coll) = new NoBuilder }
+object VectorView {
+ type Coll = TraversableView[_, C] forSome { type C <: scala.collection.Traversable[_] }
+ implicit def builderFactory[A]: BuilderFactory[A, VectorView[A, Vector[_]], Coll] = new BuilderFactory[A, VectorView[A, mutable.Vector[_]], Coll] { def apply(from: Coll) = new NoBuilder }
}
diff --git a/src/library/scala/collection/generic/MutableVectorViewTemplate.scala b/src/library/scala/collection/mutable/VectorViewLike.scala
index e4d37c830a..35f41b3a6a 100644
--- a/src/library/scala/collection/generic/MutableVectorViewTemplate.scala
+++ b/src/library/scala/collection/mutable/VectorViewLike.scala
@@ -9,8 +9,8 @@
// $Id$
-package scala.collection.generic
-import scala.collection._
+package scala.collection
+package mutable
import TraversableView.NoBuilder
@@ -19,13 +19,13 @@ import TraversableView.NoBuilder
* @author Martin Odersky
* @version 2.8
*/
-trait MutableVectorViewTemplate[A,
- +Coll,
- +This <: MutableVectorView[A, Coll] with MutableVectorViewTemplate[A, Coll, This]]
- extends mutable.Vector[A] with MutableVectorTemplate[A, This] with VectorView[A, Coll] with VectorViewTemplate[A, Coll, This]
+trait VectorViewLike[A,
+ +Coll,
+ +This <: VectorView[A, Coll] with VectorViewLike[A, Coll, This]]
+ extends Vector[A] with VectorLike[A, This] with scala.collection.VectorView[A, Coll] with scala.collection.VectorViewLike[A, Coll, This]
{ self =>
- trait Transformed[B] extends MutableVectorView[B, Coll] with super.Transformed[B] {
+ trait Transformed[B] extends VectorView[B, Coll] with super.Transformed[B] {
def update(idx: Int, elem: B)
}
diff --git a/src/library/scala/collection/mutable/WeakHashMap.scala b/src/library/scala/collection/mutable/WeakHashMap.scala
index a24786ac9d..8c23a99e51 100644
--- a/src/library/scala/collection/mutable/WeakHashMap.scala
+++ b/src/library/scala/collection/mutable/WeakHashMap.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.JavaConversions._
+import JavaConversions._
class WeakHashMap[A, B] extends JMapWrapper[A, B](new java.util.WeakHashMap) {
override def empty = new WeakHashMap[A, B]
diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala
index b3bcc568c3..9f5d3d4414 100644
--- a/src/library/scala/collection/mutable/WrappedArray.scala
+++ b/src/library/scala/collection/mutable/WrappedArray.scala
@@ -9,11 +9,12 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
import Predef._
import scala.reflect.ClassManifest
-import collection.generic._
+import scala.collection.generic._
/**
* <p>A class representing <code>Array[T]</code></p>
@@ -52,16 +53,16 @@ abstract class WrappedArray[T] extends Vector[T] with ArrayLike[T, WrappedArray[
object WrappedArray {
def make[T](x: AnyRef): WrappedArray[T] = x match {
- case x: Array[AnyRef] => wrapArray[AnyRef](x).asInstanceOf[WrappedArray[T]]
- case x: Array[Int] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Double] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Long] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Float] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Char] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Byte] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Short] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Boolean] => wrapArray(x).asInstanceOf[WrappedArray[T]]
- case x: Array[Unit] => wrapArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[AnyRef] => wrapRefArray[AnyRef](x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Int] => wrapIntArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Double] => wrapDoubleArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Long] => wrapLongArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Float] => wrapFloatArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Char] => wrapCharArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Byte] => wrapByteArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Short] => wrapShortArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Boolean] => wrapBooleanArray(x).asInstanceOf[WrappedArray[T]]
+ case x: Array[Unit] => wrapUnitArray(x).asInstanceOf[WrappedArray[T]]
}
implicit def builderFactory[T](implicit m: ClassManifest[T]): BuilderFactory[T, WrappedArray[T], WrappedArray[_]] =
diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
index 96cdef6390..4544510f84 100644
--- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
@@ -9,9 +9,10 @@
// $Id$
-package scala.collection.mutable
+package scala.collection
+package mutable
-import scala.collection.generic._
+import generic._
import scala.reflect.ClassManifest
/** A builder class for arrays */
diff --git a/src/library/scala/collection/script/Location.scala b/src/library/scala/collection/script/Location.scala
index f582d1e923..7819d23d02 100644
--- a/src/library/scala/collection/script/Location.scala
+++ b/src/library/scala/collection/script/Location.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.script
+package scala.collection
+package script
/** Class <code>Location</code> describes locations in messages implemented by
diff --git a/src/library/scala/collection/script/Message.scala b/src/library/scala/collection/script/Message.scala
index d12cb418a5..2a9974c28d 100644
--- a/src/library/scala/collection/script/Message.scala
+++ b/src/library/scala/collection/script/Message.scala
@@ -9,8 +9,8 @@
// $Id$
-package scala.collection.script
-import scala.collection._
+package scala.collection
+package script
import Predef._
import mutable.ArrayBuffer
diff --git a/src/library/scala/collection/script/Scriptable.scala b/src/library/scala/collection/script/Scriptable.scala
index 86a804502d..5c777463a2 100644
--- a/src/library/scala/collection/script/Scriptable.scala
+++ b/src/library/scala/collection/script/Scriptable.scala
@@ -9,7 +9,8 @@
// $Id$
-package scala.collection.script
+package scala.collection
+package script
/** Classes that mix in the <code>Scriptable</code> class allow
diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala
index 3e815d16a4..dd0f5ddf94 100644
--- a/src/library/scala/runtime/BoxedArray.scala
+++ b/src/library/scala/runtime/BoxedArray.scala
@@ -13,8 +13,7 @@ package scala.runtime
import Predef._
import scala.reflect.ClassManifest
-import collection.mutable.{Vector, ArrayBuilder, ArrayBuffer}
-import collection.generic._
+import collection.mutable._
import collection.Sequence
/**
@@ -23,7 +22,7 @@ import collection.Sequence
* @author Martin Odersky, Stephane Micheloud
* @version 1.0
*/
-abstract class BoxedArray[A] extends Vector[A] with VectorTemplate[A, BoxedArray[A]] with Boxed { self =>
+abstract class BoxedArray[A] extends Vector[A] with VectorLike[A, BoxedArray[A]] with Boxed { self =>
val ex = new Error("trying to create a BoxedArray")
ex.printStackTrace()
diff --git a/src/library/scala/runtime/RichChar.scala b/src/library/scala/runtime/RichChar.scala
index e79984c5a7..1f33c2681d 100644
--- a/src/library/scala/runtime/RichChar.scala
+++ b/src/library/scala/runtime/RichChar.scala
@@ -12,8 +12,7 @@
package scala.runtime
import java.lang.Character
-import collection.Vector
-import collection.generic.VectorView
+import collection.{Vector, VectorView}
import Predef.{require, NoSuchElementException}
/** <p>
diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala
index 70addde99a..dd871cf421 100644
--- a/src/library/scala/runtime/RichString.scala
+++ b/src/library/scala/runtime/RichString.scala
@@ -13,8 +13,9 @@ package scala.runtime
import scala.util.matching.Regex
import collection.generic._
-//import collection.mutable.StringBuilder
+import collection.VectorLike
import collection.immutable.Vector
+import collection.mutable.{Builder, StringBuilder}
object RichString {
@@ -31,7 +32,7 @@ object RichString {
import RichString._
-class RichString(val self: String) extends Proxy with Vector[Char] with VectorTemplate[Char, RichString] with PartialFunction[Int, Char] with Ordered[String] with Boxed {
+class RichString(val self: String) extends Proxy with Vector[Char] with VectorLike[Char, RichString] with PartialFunction[Int, Char] with Ordered[String] with Boxed {
/** Creates a string builder buffer as builder for this class */
override protected[this] def newBuilder = RichString.newBuilder
diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala
index 09828f7652..8f2e3a994d 100644
--- a/src/library/scala/xml/NodeSeq.scala
+++ b/src/library/scala/xml/NodeSeq.scala
@@ -12,8 +12,9 @@
package scala.xml
import collection.immutable
-import collection.generic._
-import collection.mutable.ListBuffer
+import collection.SequenceLike
+import collection.mutable.{Builder, ListBuffer}
+import collection.generic.BuilderFactory
/** This object ...
*
@@ -37,7 +38,7 @@ object NodeSeq {
* @author Burak Emir
* @version 1.0
*/
-abstract class NodeSeq extends immutable.Sequence[Node] with SequenceTemplate[Node, NodeSeq] {
+abstract class NodeSeq extends immutable.Sequence[Node] with SequenceLike[Node, NodeSeq] {
import NodeSeq.seqToNodeSeq // import view magic for NodeSeq wrappers
/** Creates a list buffer as builder for this class */
diff --git a/test/files/neg/bug876.check b/test/files/neg/bug876.check
index e4be7e3351..85522423a8 100644
--- a/test/files/neg/bug876.check
+++ b/test/files/neg/bug876.check
@@ -1,4 +1,4 @@
-bug876.scala:25: error: too many arguments for method apply: (key: AssertionError.A)manager.B in trait MapTemplate
+bug876.scala:25: error: too many arguments for method apply: (key: AssertionError.A)manager.B in trait MapLike
assert(manager.map(A2) == List(manager.map(A2, A1)))
^
one error found
diff --git a/test/files/neg/t2031.check b/test/files/neg/t2031.check
index 6fd70143eb..1e58fd795c 100644
--- a/test/files/neg/t2031.check
+++ b/test/files/neg/t2031.check
@@ -1,5 +1,5 @@
t2031.scala:8: error: polymorphic expression cannot be instantiated to expected type;
- found : [A]scala.collection.generic.Builder[A,scala.collection.immutable.TreeSet[A]]
+ found : [A]scala.collection.mutable.Builder[A,scala.collection.immutable.TreeSet[A]]
required: scala.collection.generic.BuilderFactory[Int,?,scala.collection.immutable.TreeSet[Int]]
res0.map(x => x)(TreeSet.newBuilder)
^
diff --git a/test/files/pos/spec-List.scala b/test/files/pos/spec-List.scala
index 7dce0305a9..7cd6a03f6c 100644
--- a/test/files/pos/spec-List.scala
+++ b/test/files/pos/spec-List.scala
@@ -7,10 +7,12 @@
\* */
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.mutable.ListBuffer
-import scala.collection.generic._
+import generic._
+import mutable.{Builder, ListBuffer}
+import annotation.tailrec
/** A class representing an ordered collection of elements of type
* <code>a</code>. This class comes with two implementing case
@@ -23,11 +25,11 @@ import scala.collection.generic._
*/
sealed abstract class List[@specialized +A] extends LinearSequence[A]
with Product
- with TraversableClass[A, List]
- with LinearSequenceTemplate[A, List[A]] {
- override def companion: Companion[List] = List
+ with GenericTraversableTemplate[A, List]
+ with LinearSequenceLike[A, List[A]] {
+ override def companion: GenericCompanion[List] = List
- import collection.{Iterable, Traversable, Sequence, Vector}
+ import scala.collection.{Iterable, Traversable, Sequence, Vector}
/** Returns true if the list does not contain any elements.
* @return <code>true</code>, iff the list is empty.
@@ -100,6 +102,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* @return the reversed list of results.
*/
def reverseMap[B](f: A => B): List[B] = {
+ @tailrec
def loop(l: List[A], res: List[B]): List[B] = l match {
case Nil => res
case head :: tail => loop(tail, f(head) :: res)
@@ -136,7 +139,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
loop(this)
}
- // Overridden methods from IterableTemplate or overloaded variants of such methods
+ // Overridden methods from IterableLike or overloaded variants of such methods
/** Create a new list which contains all elements of this list
* followed by all elements of Traversable `that'
@@ -212,6 +215,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* @return the suffix of length <code>n</code> of the list
*/
override def takeRight(n: Int): List[A] = {
+ @tailrec
def loop(lead: List[A], lag: List[A]): List[A] = lead match {
case Nil => lag
case _ :: tail => loop(tail, lag.tail)
@@ -264,9 +268,14 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* @return the longest suffix of the list whose first element
* does not satisfy the predicate <code>p</code>.
*/
- override def dropWhile(p: A => Boolean): List[A] =
- if (isEmpty || !p(head)) this
- else tail dropWhile p
+ override def dropWhile(p: A => Boolean): List[A] = {
+ @tailrec
+ def loop(xs: List[A]): List[A] =
+ if (xs.isEmpty || !p(xs.head)) xs
+ else loop(xs.tail)
+
+ loop(this)
+ }
/** Returns the longest prefix of the list whose elements all satisfy
* the given predicate, and the rest of the list.
@@ -346,7 +355,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
* which should be true iff <code>e1</code> is smaller than
* <code>e2</code>.
- * !!! todo: move sorting to IterableTemplate
+ * !!! todo: move sorting to IterableLike
* </p>
*
* @param lt the comparison function
@@ -435,6 +444,7 @@ case object Nil extends List[Nothing] {
throw new NoSuchElementException("head of empty list")
override def tail: List[Nothing] =
throw new NoSuchElementException("tail of empty list")
+ // Removal of equals method here might lead to an infinite recusion similar to IntMap.equals.
override def equals(that: Any) = that match {
case that1: Sequence[_] => that1.isEmpty
case _ => false
diff --git a/test/files/run/t2074_2.check b/test/files/run/t2074_2.check
index 6bb1d596bd..416b327bd0 100644
--- a/test/files/run/t2074_2.check
+++ b/test/files/run/t2074_2.check
@@ -1 +1,3 @@
-VectorViewTemplateZ((1,1), (2,2), (3,3))
+VectorView(1, 2, 3)
+VectorView(1, 2, 3)
+VectorViewZ((1,1), (2,2), (3,3))
diff --git a/test/files/run/t2074_2.scala b/test/files/run/t2074_2.scala
index 6aca6c3f60..24fa6c7601 100644
--- a/test/files/run/t2074_2.scala
+++ b/test/files/run/t2074_2.scala
@@ -1,5 +1,5 @@
import scala.collection.immutable.Vector
-import scala.collection.generic.VectorView
+import scala.collection.VectorView
object Test {
val v = new VectorView[Int, Vector[Int]] {
@@ -7,8 +7,11 @@ object Test {
def apply(idx: Int) = underlying(idx)
def length = underlying.length
}
+ val w = Vector(1, 2, 3).view
def main(args: Array[String]): Unit = {
+ println(v)
+ println(w)
println(go)
}
def go = v zip v