diff options
author | Paul Phillips <paulp@improving.org> | 2011-11-07 18:22:51 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-11-07 18:22:51 +0000 |
commit | 481096f2c56fbf1b14fff2142917a46668b7c3b2 (patch) | |
tree | 5706019d5e00484f5d8ae2abb9a4bcbd9d904026 /src | |
parent | a0a045f5c0b5aa6ed02c849c4ab013cfbfd4e24f (diff) | |
download | scala-481096f2c56fbf1b14fff2142917a46668b7c3b2.tar.gz scala-481096f2c56fbf1b14fff2142917a46668b7c3b2.tar.bz2 scala-481096f2c56fbf1b14fff2142917a46668b7c3b2.zip |
Next collections commit from Todd Vierling.
Changes to library code outside the collections.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/Enumeration.scala | 8 | ||||
-rw-r--r-- | src/library/scala/Predef.scala | 4 | ||||
-rw-r--r-- | src/library/scala/Product.scala | 2 | ||||
-rw-r--r-- | src/library/scala/io/BufferedSource.scala | 4 | ||||
-rw-r--r-- | src/library/scala/io/Source.scala | 3 | ||||
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 4 | ||||
-rw-r--r-- | src/library/scala/util/matching/Regex.scala | 11 | ||||
-rw-r--r-- | src/library/scala/xml/NodeSeq.scala | 4 |
8 files changed, 23 insertions, 17 deletions
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index 65a5cfb55a..07e758013c 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -8,7 +8,7 @@ package scala -import scala.collection.{ mutable, immutable, generic, SetLike } +import scala.collection.{ mutable, immutable, generic, SetLike, AbstractSet } import java.lang.reflect.{ Modifier, Method => JMethod, Field => JField } import scala.reflect.NameTransformer._ import java.util.regex.Pattern @@ -235,7 +235,11 @@ abstract class Enumeration(initial: Int, names: String*) extends Serializable { * * @param ids The set of ids of values, organized as a `SortedSet`. */ - class ValueSet private[Enumeration] (val ids: immutable.SortedSet[Int]) extends Set[Value] with SetLike[Value, ValueSet] { + class ValueSet private[Enumeration] (val ids: immutable.SortedSet[Int]) + extends AbstractSet[Value] + with 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/Predef.scala b/src/library/scala/Predef.scala index 018cbdefd7..fb3f379b0c 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -280,12 +280,12 @@ object Predef extends LowPriorityImplicits { implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc) implicit def zipped2ToTraversable[El1, El2](zz: Tuple2[_, _]#Zipped[_, El1, _, El2]): Traversable[(El1, El2)] = - new Traversable[(El1, El2)] { + new collection.AbstractTraversable[(El1, El2)] { def foreach[U](f: ((El1, El2)) => U): Unit = zz foreach Function.untupled(f) } implicit def zipped3ToTraversable[El1, El2, El3](zz: Tuple3[_, _, _]#Zipped[_, El1, _, El2, _, El3]): Traversable[(El1, El2, El3)] = - new Traversable[(El1, El2, El3)] { + new collection.AbstractTraversable[(El1, El2, El3)] { def foreach[U](f: ((El1, El2, El3)) => U): Unit = zz foreach Function.untupled(f) } diff --git a/src/library/scala/Product.scala b/src/library/scala/Product.scala index 53a838ee9d..90ae82b6d0 100644 --- a/src/library/scala/Product.scala +++ b/src/library/scala/Product.scala @@ -35,7 +35,7 @@ trait Product extends Equals { /** An iterator over all the elements of this product. * @return in the default implementation, an `Iterator[Any]` */ - def productIterator: Iterator[Any] = new Iterator[Any] { + def productIterator: Iterator[Any] = new collection.AbstractIterator[Any] { private var c: Int = 0 private val cmax = productArity def hasNext = c < cmax diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala index b5144a891f..a82cc45aa6 100644 --- a/src/library/scala/io/BufferedSource.scala +++ b/src/library/scala/io/BufferedSource.scala @@ -10,7 +10,7 @@ package scala.io import java.io.{ InputStream, BufferedReader, InputStreamReader, PushbackReader } import Source.DefaultBufSize -import scala.collection.Iterator +import scala.collection.{ Iterator, AbstractIterator } /** This object provides convenience methods to create an iterable * representation of a source file. @@ -40,7 +40,7 @@ class BufferedSource(inputStream: InputStream, bufferSize: Int)(implicit val cod map (_.toChar) ) - class BufferedLineIterator extends Iterator[String] { + class BufferedLineIterator extends AbstractIterator[String] with Iterator[String] { // Don't want to lose a buffered char sitting in iter either. Yes, // this is ridiculous, but if I can't get rid of Source, and all the // Iterator bits are designed into Source, and people create Sources diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index 3c2df1b9b8..e7bcc32558 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -8,6 +8,7 @@ package scala.io +import scala.collection.AbstractIterator import java.io.{ FileInputStream, InputStream, PrintStream, File => JFile } import java.net.{ URI, URL } @@ -189,7 +190,7 @@ abstract class Source extends Iterator[Char] { private def lineNum(line: Int): String = getLines() drop (line - 1) take 1 mkString - class LineIterator() extends Iterator[String] { + class LineIterator() extends AbstractIterator[String] { private[this] val sb = new StringBuilder lazy val iter: BufferedIterator[Char] = Source.this.iter.buffered diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 33f93e610d..aa4830369e 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -8,7 +8,7 @@ package scala.runtime -import scala.collection.{ Seq, IndexedSeq, TraversableView } +import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator } import scala.collection.mutable.WrappedArray import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: } import scala.collection.generic.{ Sorted } @@ -178,7 +178,7 @@ object ScalaRunTime { /** A helper for case classes. */ def typedProductIterator[T](x: Product): Iterator[T] = { - new Iterator[T] { + new AbstractIterator[T] { private var c: Int = 0 private val cmax = x.productArity def hasNext = c < cmax diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 12b4ad84bf..28ba226324 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -30,6 +30,7 @@ */ package scala.util.matching +import scala.collection.AbstractIterator import java.util.regex.{ Pattern, Matcher } /** This class provides methods for creating and using regular expressions. @@ -187,7 +188,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * match, subgroups, etc. * * @param source The text to match against. - * @return A [[scala.util.matching.Reegex.MatchIterator]] of all matches. + * @return A [[scala.util.matching.Regex.MatchIterator]] of all matches. * @example {{{for (words <- """\w+""".r findAllIn "A simple example.") yield words}}} */ def findAllIn(source: java.lang.CharSequence) = new Regex.MatchIterator(source, this, groupNames) @@ -502,7 +503,7 @@ object Regex { /** A class to step through a sequence of regex matches */ class MatchIterator(val source: java.lang.CharSequence, val regex: Regex, val groupNames: Seq[String]) - extends Iterator[String] with MatchData { self => + extends AbstractIterator[String] with Iterator[String] with MatchData { self => protected val matcher = regex.pattern.matcher(source) private var nextSeen = false @@ -520,7 +521,7 @@ object Regex { matcher.group } - override def toString = super[Iterator].toString + override def toString = super[AbstractIterator].toString /** The index of the first matched character */ def start: Int = matcher.start @@ -538,13 +539,13 @@ object Regex { def groupCount = matcher.groupCount /** Convert to an iterator that yields MatchData elements instead of Strings */ - def matchData = new Iterator[Match] { + def matchData: Iterator[Match] = new AbstractIterator[Match] { def hasNext = self.hasNext def next = { self.next; new Match(source, matcher, groupNames).force } } /** Convert to an iterator that yields MatchData elements instead of Strings and has replacement support */ - private[matching] def replacementData = new Iterator[Match] with Replacement { + private[matching] def replacementData = new AbstractIterator[Match] with Replacement { def matcher = self.matcher def hasNext = self.hasNext def next = { self.next; new Match(source, matcher, groupNames).force } diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index 1a28b2489e..ff5618645f 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -8,7 +8,7 @@ package scala.xml -import collection.{ mutable, immutable, generic, SeqLike } +import collection.{ mutable, immutable, generic, SeqLike, AbstractSeq } import mutable.{ Builder, ListBuffer } import generic.{ CanBuildFrom } @@ -38,7 +38,7 @@ object NodeSeq { * @author Burak Emir * @version 1.0 */ -abstract class NodeSeq extends immutable.Seq[Node] with SeqLike[Node, NodeSeq] with Equality { +abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with SeqLike[Node, NodeSeq] with Equality { import NodeSeq.seqToNodeSeq // import view magic for NodeSeq wrappers /** Creates a list buffer as builder for this class */ |