diff options
author | mihaylov <mihaylov@epfl.ch> | 2007-07-19 21:11:21 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2007-07-19 21:11:21 +0000 |
commit | 247ec20681e3f7991e73c9ffc84859f9d6a0d838 (patch) | |
tree | 55037e4859b5a1b49239bd27fc1391123648af17 /src | |
parent | e0fa88b7295431a4b0efae4cac2ad9680a11ac88 (diff) | |
download | scala-247ec20681e3f7991e73c9ffc84859f9d6a0d838.tar.gz scala-247ec20681e3f7991e73c9ffc84859f9d6a0d838.tar.bz2 scala-247ec20681e3f7991e73c9ffc84859f9d6a0d838.zip |
Synced dotnet-library/ with rev 12365
Diffstat (limited to 'src')
-rw-r--r-- | src/dotnet-library/scala/Predef.scala | 5 | ||||
-rw-r--r-- | src/dotnet-library/scala/compat/StringBuilder.scala | 2 | ||||
-rw-r--r-- | src/dotnet-library/scala/runtime/RichString.scala | 48 | ||||
-rw-r--r-- | src/library/scala/BufferedIterator.scala | 3 |
4 files changed, 43 insertions, 15 deletions
diff --git a/src/dotnet-library/scala/Predef.scala b/src/dotnet-library/scala/Predef.scala index 26d9928ebb..493ee84b91 100644 --- a/src/dotnet-library/scala/Predef.scala +++ b/src/dotnet-library/scala/Predef.scala @@ -35,7 +35,9 @@ object Predef { type boolean = scala.Boolean type unit = scala.Unit - @deprecated type All = Nothing + /** @deprecated use <code>Nothing</code> instead */ + @deprecated type All = Nothing + /** @deprecated use <code>Null</code> instead */ @deprecated type AllRef = Null type String = System.String @@ -167,6 +169,7 @@ object Predef { implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x) implicit def stringWrapper(x: String) = new runtime.RichString(x) + //implicit def stringBuilderWrapper(x : StringBuilder) = new runtime.RichStringBuilder(x) implicit def any2stringadd(x: Any) = new runtime.StringAdd(x) diff --git a/src/dotnet-library/scala/compat/StringBuilder.scala b/src/dotnet-library/scala/compat/StringBuilder.scala index a006e4fe1a..2ce9ad178f 100644 --- a/src/dotnet-library/scala/compat/StringBuilder.scala +++ b/src/dotnet-library/scala/compat/StringBuilder.scala @@ -34,7 +34,7 @@ final class StringBuilder(val self: StringBuffer) extends (Int => Char) with Pro def charAt(i: Int): Char = self(i) def apply(i: Int): Char = self(i) - def deleteCharAt(index: Int) = self.Remote(index, 1) + def deleteCharAt(index: Int) = self.Remove(index, 1) def setCharAt(i: Int, c: Char) { self(i) = c } def update(i: Int, c: Char) { self(i) = c } diff --git a/src/dotnet-library/scala/runtime/RichString.scala b/src/dotnet-library/scala/runtime/RichString.scala index 19085eee88..2f43f5e7c7 100644 --- a/src/dotnet-library/scala/runtime/RichString.scala +++ b/src/dotnet-library/scala/runtime/RichString.scala @@ -14,21 +14,43 @@ package scala.runtime import Predef._ -final class RichString(val self: String) extends Seq[Char] with Ordered[String] with Proxy { - - // Ordered[String] - def compare(other: String) = self compareTo other +final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char] with Ordered[String] { + override def apply(n: Int) = self charAt n + override def length = self.length + override def toString = self + override def mkString = self + override def slice(from : Int, until : Int) : RichString = { + val from0 = if (from < 0) 0 else from + val until0 = if (from >= until || from >= self.length) return new RichString("") + else if (until > self.length) self.length else until + new RichString(self.substring(from0, until0)) + } + //override def ++ [B >: A](that: Iterable[B]): Seq[B] = { + override def ++[B >: Char](that : Iterable[B]) : RandomAccessSeq[B] = that match { + case that : RichString => new RichString(self + that.self) + case that => super.++(that) + } - // Seq[Char] - def length = self.length - override def elements = Iterator.fromString(self) + override def take(until : Int) : RichString = slice(0, until) + override def drop(from : Int) : RichString = slice(from, self.length) + override def startsWith[B](that : Seq[B]) = that match { + case that : RichString => self startsWith that.self + case that => super.startsWith(that) + } + override def endsWith[B](that : Seq[B]) = that match { + case that : RichString => self endsWith that.self + case that => super.endsWith(that) + } + override def indexOf[B](that : Seq[B]) = that match { + case that : RichString => self indexOf that.self + case that => super.indexOf(that) + } + override def containsSlice[B](that : Seq[B]) = that match { + case that : RichString => self contains that.self + case that => super.containsSlice(that) + } - /** Retrieve the n-th character of the string - * - * @param index into the string - * @return the character at position <code>index</code>. - */ - def apply(n: Int) = self charAt n + override def compare(other: String) = self compareTo other private final val LF: Char = 0x0A private final val FF: Char = 0x0C diff --git a/src/library/scala/BufferedIterator.scala b/src/library/scala/BufferedIterator.scala index 1b4ebef3f8..a206ccaa48 100644 --- a/src/library/scala/BufferedIterator.scala +++ b/src/library/scala/BufferedIterator.scala @@ -11,6 +11,9 @@ package scala + +import Predef._ + /** Buffered iterators are iterators which allow to inspect the next * element without discarding it. * |