Synced dotnet-library/ with rev 12365

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@12367 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
mihaylov 2007-07-19 21:11:21 +00:00
parent 00ee246af3
commit 8b978fca22
5 changed files with 46 additions and 17 deletions

View File

@ -769,6 +769,7 @@ MSIL
<include name="scala/serializable.scala"/>
<include name="scala/transient.scala"/>
<include name="scala/runtime/*.scala"/>
<exclude name="scala/runtime/RichStringBuilder.scala"/>
</quick>
<property name="ilasm.infile" value="${msil.dir}/predef.msil"/>
<property name="ilasm.outfile" value="${msil.dir}/predef.dll"/>

View File

@ -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)

View File

@ -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 }

View File

@ -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
// Seq[Char]
def length = self.length
override def elements = Iterator.fromString(self)
/** 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
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)
}
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)
}
override def compare(other: String) = self compareTo other
private final val LF: Char = 0x0A
private final val FF: Char = 0x0C

View File

@ -11,6 +11,9 @@
package scala
import Predef._
/** Buffered iterators are iterators which allow to inspect the next
* element without discarding it.
*