summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2009-05-29 11:35:44 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2009-05-29 11:35:44 +0000
commit450425c96412a8b7ae52513dbe99af5732a19bfb (patch)
tree6963ca52753540d3892901f85b838977660f5bea
parent67fa653a4864d376732ffff8d5bd46c2c23bb4fe (diff)
downloadscala-450425c96412a8b7ae52513dbe99af5732a19bfb.tar.gz
scala-450425c96412a8b7ae52513dbe99af5732a19bfb.tar.bz2
scala-450425c96412a8b7ae52513dbe99af5732a19bfb.zip
Removed CLDC library, since we've stopper suppo...
Removed CLDC library, since we've stopper supporting CLDC.
-rw-r--r--src/cldc-library/scala/Array.scala430
-rw-r--r--src/cldc-library/scala/Console.scala96
-rw-r--r--src/cldc-library/scala/List.scala1225
-rw-r--r--src/cldc-library/scala/Math.scala56
-rw-r--r--src/cldc-library/scala/Predef.scala188
-rw-r--r--src/cldc-library/scala/Random.scala41
-rw-r--r--src/cldc-library/scala/StringBuilder.scala862
-rw-r--r--src/cldc-library/scala/Symbol.scala48
-rw-r--r--src/cldc-library/scala/collection/mutable/CloneableCollection.scala19
-rw-r--r--src/cldc-library/scala/compat/Platform.scala56
-rw-r--r--src/cldc-library/scala/runtime/BooleanRef.java19
-rw-r--r--src/cldc-library/scala/runtime/BoxedAnyArray.scala234
-rw-r--r--src/cldc-library/scala/runtime/BoxedObjectArray.scala73
-rw-r--r--src/cldc-library/scala/runtime/BoxedUnit.java33
-rw-r--r--src/cldc-library/scala/runtime/BoxesRunTime.java361
-rw-r--r--src/cldc-library/scala/runtime/BoxesUtility.java147
-rw-r--r--src/cldc-library/scala/runtime/ByteRef.java19
-rw-r--r--src/cldc-library/scala/runtime/CharRef.java19
-rw-r--r--src/cldc-library/scala/runtime/Comparator.java53
-rw-r--r--src/cldc-library/scala/runtime/IntRef.java19
-rw-r--r--src/cldc-library/scala/runtime/LongRef.java19
-rw-r--r--src/cldc-library/scala/runtime/ObjectRef.java19
-rw-r--r--src/cldc-library/scala/runtime/RichChar.scala71
-rw-r--r--src/cldc-library/scala/runtime/RichException.scala29
-rw-r--r--src/cldc-library/scala/runtime/RichLong.scala30
-rw-r--r--src/cldc-library/scala/runtime/RichString.scala219
-rw-r--r--src/cldc-library/scala/runtime/ScalaRunTime.scala142
-rw-r--r--src/cldc-library/scala/runtime/ShortRef.java19
-rw-r--r--src/cldc-library/scala/runtime/SquareRoot.scala151
-rw-r--r--src/cldc-library/scala/runtime/StringAdd.scala22
30 files changed, 0 insertions, 4719 deletions
diff --git a/src/cldc-library/scala/Array.scala b/src/cldc-library/scala/Array.scala
deleted file mode 100644
index f37c7f56b0..0000000000
--- a/src/cldc-library/scala/Array.scala
+++ /dev/null
@@ -1,430 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-
-import Predef._
-import compat.Platform.arraycopy
-
-/** This object contains utility methods operating on arrays.
- *
- * @author Martin Odersky
- * @version 1.0
- */
-object Array {
-
- /** Copy one array to another.
- * Equivalent to
- * <code>System.arraycopy(src, srcPos, dest, destPos, length)</code>,
- * except that this works also for polymorphic and boxed arrays.
- *
- * @param src ...
- * @param srcPos ...
- * @param dest ...
- * @param destPos ...
- * @param length ...
- */
- def copy(src: AnyRef, srcPos: Int, dest: AnyRef, destPos: Int, length: Int): Unit = src match {
- case xs: runtime.BoxedArray =>
- xs.copyTo(srcPos, dest, destPos, length)
- case _ =>
- dest match {
- case xs: runtime.BoxedArray =>
- xs.copyFrom(src, srcPos, destPos, length)
- case _ =>
- arraycopy(src, srcPos, dest, destPos, length)
- }
- }
-
- /** Concatenate all argument arrays into a single array.
- *
- * @param xs ...
- */
- def concat[T](xs: Array[T]*) = {
- var len = 0
- for (x <- xs) len += x.length
- val result = new Array[T](len)
- var start = 0
- for (x <- xs) {
- copy(x, 0, result, start, x.length)
- start += x.length
- }
- result
- }
-
- /** Create a an array containing of successive integers.
- *
- * @param from the value of the first element of the array
- * @param end the value of the last element fo the array plus 1
- * @return the sorted array of all integers in range [from;end).
- */
- def range(start: Int, end: Int): Array[Int] = {
- val result = new Array[Int](end - start)
- for (i <- start until end) result(i - start) = i
- result
- }
-
- /** Create an array with given elements.
- *
- * @param xs the elements to put in the array
- * @return the array containing elements xs.
- */
- def apply[A <: AnyRef](xs: A*): Array[A] = {
- val array = new Array[A](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
-
-
-/* The following metod clashes with the previous one, and has therefore been
- * removed. Note that this is a choice between efficiency and generality.
- * The previous factory method is more efficient than the one that has been
- * commented out. Since it is anyway possible to create a polymorphic array
- * using
- * new Array[T]
- * it was preferred to restrict the definition of the factory method.
-
- def Array[A](xs: A*): Array[A] = {
- val array = new Array[A](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
-*/
-
- def apply(xs: Boolean*): Array[Boolean] = {
- val array = new Array[Boolean](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
- def apply(xs: Byte*): Array[Byte] = {
- val array = new Array[Byte](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
- def apply(xs: Short*): Array[Short] = {
- val array = new Array[Short](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
- def apply(xs: Char*): Array[Char] = {
- val array = new Array[Char](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
- def apply(xs: Int*): Array[Int] = {
- val array = new Array[Int](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
- def apply(xs: Long*): Array[Long] = {
- val array = new Array[Long](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
- def apply(xs: Unit*): Array[Unit] = {
- val array = new Array[Unit](xs.length)
- var i = 0
- for (x <- xs.iterator) { array(i) = x; i += 1 }
- array
- }
-
- /** Create an array containing several copies of an element.
- *
- * @param n the length of the resulting array
- * @param elem the element composing the resulting array
- * @return an array composed of n elements all equal to elem
- */
- def make[A](n: Int, elem: A): Array[A] = {
- val a = new Array[A](n)
- var i = 0
- while (i < n) {
- a(i) = elem
- i += 1
- }
- a
- }
-
- /** This method is called as a result of a pattern match { case Array(...) => } or val Array(...) = ....
- *
- * @param x the selector value
- * @return array wrapped in an option
- */
- def unapplySeq[A](x: Array[A]): Option[Seq[A]] = Some(x)
-
- trait Projection[A] extends RandomAccessSeq.MutableProjection[A] {
- protected def newArray[B >: A](length : Int, elements : Iterator[A]) : Array[B]
- override def toArray[B >: A] = (newArray(length, elements))//:Any).asInstanceOf[Array[B]]
- override def force : Array[A] = toArray
- override def drop( from: Int) = slice(from, length)
- override def take(until: Int) = slice(0, until)
- override def slice(from0 : Int, until0 : Int) : Projection[A] = new RandomAccessSeq.MutableSlice[A] with Projection[A] {
- override def from = from0
- override def until = until0
- override def underlying = Projection.this
- override protected def newArray[B >: A](length : Int, elements : Iterator[A]) =
- underlying.newArray(length, elements)
- override def slice(from0 : Int, until0 : Int) =
- Projection.this.slice(from + from0, from + until0)
- }
- override def reverse : Projection[A] = new Projection[A] {
- override protected def newArray[B >: A](length : Int, elements : Iterator[A]) =
- Projection.this.newArray(length, elements)
- def update(idx : Int, what : A) : Unit = Projection.this.update(length - idx - 1, what)
- def length = Projection.this.length
- def apply(idx : Int) = Projection.this.apply(length - idx - 1)
- override def stringPrefix = Projection.this.stringPrefix + "R"
- }
- }
- trait Array0[A] extends RandomAccessSeq.Mutable[A] {
- override def projection : Projection[A] = throw new Error
- override def slice(from : Int, until : Int) : Projection[A] = projection.slice(from, until)
- override def take(until : Int) : Projection[A] = projection.take(until)
- override def drop(from : Int) : Projection[A] = projection.drop(from)
- override def reverse = projection.reverse
- }
-}
-
-/** This class represents polymorphic arrays. <code>Array[T]</code> is Scala's representation
- * for Java's <code>T[]</code>.
- *
- * @author Martin Odersky
- * @version 1.0
- */
-final class Array[A](_length: Int) extends Array.Array0[A] {
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int, dim7: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int, dim7: Int, dim8: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation */
- def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int, dim7: Int, dim8: Int, dim9: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** The length of the array */
- def length: Int = throw new Error()
-
- /** The element at given index.
- * <p>
- * Indices start a <code>0</code>; <code>xs.apply(0)</code> is the first
- * element of array <code>xs</code>.
- * </p>
- * <p>
- * Note the indexing syntax <code>xs(i)</code> is a shorthand for
- * <code>xs.apply(i)</code>.
- * </p>
- *
- * @param i the index
- * @throws ArrayIndexOutOfBoundsException if <code>i < 0</code> or
- * <code>length <= i</code>
- */
- def apply(i: Int): A = throw new Error()
-
- /** <p>
- * Update the element at given index.
- * </p>
- * <p>
- * Indices start a <code>0</code>; <code>xs.apply(0)</code> is the first
- * element of array <code>xs</code>.
- * </p>
- * <p>
- * Note the indexing syntax <code>xs(i) = x</code> is a shorthand
- * for <code>xs.update(i, x)</code>.
- * </p>
- *
- * @param i the index
- * @param x the value to be written at index <code>i</code>
- * @throws ArrayIndexOutOfBoundsException if <code>i < 0</code> or
- * <code>length <= i</code>
- */
- override def update(i: Int, x: A): Unit = throw new Error()
-
- /** An iterator returning the elements of this array, starting from 0.
- */
- override def iterator: Iterator[A] = throw new Error()
-
- /** @deprecated use <code>slice(from,end).force</code> instead */
- def subArray(from: Int, end: Int): Array[A] = throw new Error()
-
- /** Returns an array consisting of all elements of this array that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- *
- * @param p the predicate used to filter the array.
- * @return the elements of this array satisfying <code>p</code>.
- */
- override def filter(p: A => Boolean): Array[A] = throw new Error()
-
- /** Returns the longest prefix of this array whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @return the longest prefix of this array whose elements satisfy
- * the predicate <code>p</code>.
- */
- override def takeWhile(p: A => Boolean): Array[A] = throw new Error()
-
- /** Returns the longest suffix of this array whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @return the longest suffix of the array whose first element
- * does not satisfy the predicate <code>p</code>.
- */
- override def dropWhile(p: A => Boolean): Array[A] = throw new Error()
-
- /** Returns an array consisting of all elements of this array followed
- * by all elements of the argument iterable.
- */
- override def ++[B >: A](that: Iterable[B]): Array[B] = throw new Error()
-
- /** Returns the array resulting from applying the given function <code>f</code> to each
- * element of this array.
- *
- * @param f function to apply to each element.
- * @return <code>[f(a0), ..., f(an)]</code> if this array is <code>[a0, ..., an]</code>.
- */
- override def map[B](f: A => B): Array[B] = throw new Error()
-
- /** Applies the given function <code>f</code> to each element of
- * this array, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this array is <code>[a<sub>0</sub>, ..., a<sub>n</sub>]</code>.
- */
- override def flatMap[B](f: A => Iterable[B]): Array[B] = throw new Error()
-
- /** Returns an array formed from this array and the specified array
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two arrays is longer than the other, its remaining elements are ignored.
- *
- * @return <code>Array({a<sub>0</sub>,b<sub>0</sub>}, ...,
- * {a<sub>min(m,n)</sub>,b<sub>min(m,n)</sub>})</code> when
- * <code>Array(a<sub>0</sub>, ..., a<sub>m</sub>)
- * zip Array(b<sub>0</sub>, ..., b<sub>n</sub>)</code> is invoked.
- */
- def zip[B](that: Array[B]): Array[Tuple2[A,B]] = throw new Error()
-
- /** Returns an array that pairs each element of this array
- * with its index, counting from 0.
- *
- * @return the array <code>Array({a<sub>0</sub>,0}, {a<sub>1</sub>,1},...)</code>
- * where <code>a<sub>i</sub></code> are the elements of this stream.
- */
- def zipWithIndex: Array[Tuple2[A,Int]] = throw new Error()
-
- /** Returns an array that contains all indices of this array */
- def indices: Array[Int] = throw new Error()
-
- /**
- * @return a deep string representation of this array.
- */
- def deepToString(): String = throw new Error()
-
- /** <p>
- * Returns a string representation of this array object. The resulting string
- * begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>deepToString()</code>) are separated by the string
- * <code>sep</code>. For example:
- * </p>
- * <p>
- * <code>Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]") = "[[1; 2]; [3]]"</code>
- * </p>
- *
- * @param start starting string.
- * @param sep separator string.
- * @param end ending string.
- * @return a string representation of this array object.
- */
- def deepMkString(start: String, sep: String, end: String): String =
- throw new Error()
-
- /** Returns a string representation of this array object. The string
- * representations of elements (w.r.t. the method <code>deepToString()</code>)
- * are separated by the string <code>sep</code>.
- *
- * @param sep separator string.
- * @return a string representation of this array object.
- */
- def deepMkString(sep: String): String = throw new Error()
-
- /** <p>
- * Returns <code>true</code> if the two specified arrays are
- * <em>deeply equal</em> to one another.
- * </p>
- * <p>
- * Two array references are considered deeply equal if both are null,
- * or if they refer to arrays that contain the same number of elements
- * and all corresponding pairs of elements in the two arrays are deeply
- * equal.
- * </p>
- * <p>
- * See also method <code>deepEquals</code> in the Java class
- * <a href="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html"
- * target="_top">java.utils.Arrays</a>
- * </p>
- *
- * @param that the second
- * @return <code>true</code> iff both arrays are deeply equal.
- */
- def deepEquals(that: Any): Boolean = throw new Error()
-
-}
diff --git a/src/cldc-library/scala/Console.scala b/src/cldc-library/scala/Console.scala
deleted file mode 100644
index 1b359359c2..0000000000
--- a/src/cldc-library/scala/Console.scala
+++ /dev/null
@@ -1,96 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-import java.io.{OutputStream, PrintStream}
-
-import Predef._
-
-
-/** The <code>Console</code> object implements functionality for
- * printing Scala values on the terminal. There are also functions
- * for reading specific values. <code>Console</code> also defines
- * constants for marking up text on ANSI terminals.
- *
- * @author Matthias Zenger
- * @version 1.0, 03/09/2003
- */
-object Console {
-
- // ANSI colors foreground
- final val BLACK = "\033[30m"
- final val RED = "\033[31m"
- final val GREEN = "\033[32m"
- final val YELLOW = "\033[33m"
- final val BLUE = "\033[34m"
- final val MAGENTA = "\033[35m"
- final val CYAN = "\033[36m"
- final val WHITE = "\033[37m"
-
- // ANSI colors background
- final val BLACK_B = "\033[40m"
- final val RED_B = "\033[41m"
- final val GREEN_B = "\033[42m"
- final val YELLOW_B = "\033[43m"
- final val BLUE_B = "\033[44m"
- final val MAGENTA_B = "\033[45m"
- final val CYAN_B = "\033[46m"
- final val WHITE_B = "\033[47m"
-
- // ANSI styles
- final val RESET = "\033[0m"
- final val BOLD = "\033[1m"
- final val UNDERLINED = "\033[4m"
- final val BLINK = "\033[5m"
- final val REVERSED = "\033[7m"
- final val INVISIBLE = "\033[8m"
-
- var out: PrintStream = java.lang.System.out
- val err = java.lang.System.err
-
- /** Set the default output stream.
- *
- * @param out the new output stream.
- */
- def setOut(out: PrintStream): Unit = this.out = out
-
- /** Set the default output stream.
- *
- * @param@ out the new output stream.
- */
- def setOut(out: OutputStream): Unit =
- setOut(new PrintStream(out))
-
- /** Print an object on the terminal.
- *
- * @param obj the object to print.
- */
- def print(obj: Any): Unit =
- out.print(if (null == obj) "null" else obj.toString())
-
- /** Flush the output stream. This function is required when partial
- * output (i.e. output not terminated by a new line character) has
- * to be made visible on the terminal.
- */
- def flush(): Unit = out.flush()
-
- /** Print a new line character on the terminal.
- */
- def println(): Unit = out.println()
-
- /** Print out an object followed by a new line character.
- *
- * @param x the object to print.
- */
- def println(x: Any): Unit = out.println(x)
-
-}
diff --git a/src/cldc-library/scala/List.scala b/src/cldc-library/scala/List.scala
deleted file mode 100644
index 35f8d45760..0000000000
--- a/src/cldc-library/scala/List.scala
+++ /dev/null
@@ -1,1225 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-import scala.collection.mutable.ListBuffer
-import Predef._
-
-/** This object provides methods for creating specialized lists, and for
- * transforming special kinds of lists (e.g. lists of lists).
- *
- * @author Martin Odersky and others
- * @version 1.0, 15/07/2003
- */
-object List {
-
- /** Create a list with given elements.
- *
- * @param xs the elements to put in the list
- * @return the list containing elements xs.
- */
- def apply[A](xs: A*): List[A] = xs.toList
-
- /** for unapply matching
- */
- def unapplySeq[A](x: List[A]): Some[List[A]] = Some(x)
-
- /** Create a sorted list of all integers in a range.
- *
- * @param from the start value of the list
- * @param end the end value of the list
- * @return the sorted list of all integers in range [from;end).
- */
- def range(from: Int, end: Int): List[Int] =
- range(from, end, 1)
-
- /** Create a sorted list of all integers in a range.
- *
- * @param from the start value of the list
- * @param end the end value of the list
- * @param step the increment value of the list
- * @return the sorted list of all integers in range [from;end).
- */
- def range(from: Int, end: Int, step: Int): List[Int] = {
- val b = new ListBuffer[Int]
- var i = from
- while (i < end) {
- b += i
- i += step
- }
- b.toList
- }
-
- /** Create a sorted list of all integers in a range.
- *
- * @param from the start value of the list
- * @param end the end value of the list
- * @param step the increment function of the list
- * @return the sorted list of all integers in range [from;end).
- */
- def range(from: Int, end: Int, step: Int => Int): List[Int] = {
- val b = new ListBuffer[Int]
- var i = from
- while (i < end) {
- b += i
- i += step(i)
- }
- b.toList
- }
-
- /** Create a list containing several copies of an element.
- *
- * @param n the length of the resulting list
- * @param elem the element composing the resulting list
- * @return a list composed of n elements all equal to elem
- */
- def make[A](n: Int, elem: A): List[A] = {
- val b = new ListBuffer[A]
- var i = 0
- while (i < n) {
- b += elem
- i += 1
- }
- b.toList
- }
-
- /** Create a list by applying a function to successive integers.
- *
- * @param n the length of the resulting list
- * @param maker the procedure which, given an integer <code>n</code>,
- * returns the nth element of the resulting list, where
- * <code>n</code> is in interval <code>[0;n)</code>.
- * @return the list obtained by applying the maker function to
- * successive integers from 0 to n (exclusive).
- */
- def tabulate[A](n: Int, maker: Int => A): List[A] = {
- val b = new ListBuffer[A]
- var i = 0
- while (i < n) {
- b += maker(i)
- i += 1
- }
- b.toList
- }
-
- /** Concatenate all the elements of a given list of lists.
- *
- * @param xss the list of lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- def flatten[A](xss: List[List[A]]): List[A] = concat(xss: _*)
-
- /** Concatenate all the argument lists into a single list.
- *
- * @param xss the lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- def concat[A](xss: List[A]*): List[A] = {
- val b = new ListBuffer[A]
- for (xs <- xss) {
- var xc = xs
- while (!xc.isEmpty) {
- b += xc.head
- xc = xc.tail
- }
- }
- b.toList
- }
-
- /** Transforms a list of pair into a pair of lists.
- *
- * @param xs the list of pairs to unzip
- * @return a pair of lists: the first list in the pair contains the list
- */
- def unzip[A,B](xs: List[(A,B)]): (List[A], List[B]) = {
- val b1 = new ListBuffer[A]
- val b2 = new ListBuffer[B]
- var xc = xs
- while (!xc.isEmpty) {
- b1 += xc.head._1
- b2 += xc.head._2
- xc = xc.tail
- }
- (b1.toList, b2.toList)
- }
-
- /** Converts an iterator to a list.
- *
- * @param it the iterator to convert
- * @return a list that contains the elements returned by successive
- * calls to <code>it.next</code>
- */
- def fromIterator[A](it: Iterator[A]): List[A] = it.toList
-
- /** Converts an array into a list.
- *
- * @param arr the array to convert
- * @return a list that contains the same elements than <code>arr</code>
- * in the same order
- */
- def fromArray[A](arr: Array[A]): List[A] = fromArray(arr, 0, arr.length)
-
- /** Converts a range of an array into a list.
- *
- * @param arr the array to convert
- * @param start the first index to consider
- * @param len the lenght of the range to convert
- * @return a list that contains the same elements than <code>arr</code>
- * in the same order
- */
- def fromArray[A](arr: Array[A], start: Int, len: Int): List[A] = {
- var res: List[A] = Nil
- var i = start + len
- while (i > start) {
- i -= 1
- res = arr(i) :: res
- }
- res
- }
-
- /** Parses a string which contains substrings separated by a
- * separator character and returns a list of all substrings.
- *
- * @param str the string to parse
- * @param separator the separator character
- * @return the list of substrings
- */
- def fromString(str: String, separator: Char): List[String] = {
- var words: List[String] = Nil
- var pos = str.length()
- while (pos > 0) {
- val pos1 = str.lastIndexOf(separator, pos - 1)
- if (pos1 + 1 < pos)
- words = str.substring(pos1 + 1, pos) :: words
- pos = pos1
- }
- words
- }
-
- /** Returns the given string as a list of characters.
- *
- * @param str the string to convert.
- * @return the string as a list of characters.
- * @deprecated use <code>str.toList</code> instead
- */
- @deprecated def fromString(str: String): List[Char] =
- str.toList
-
- /** Returns the given list of characters as a string.
- *
- * @param xs the list to convert.
- * @return the list in form of a string.
- */
- def toString(xs: List[Char]): String = {
- val sb = new StringBuilder()
- var xc = xs
- while (!xc.isEmpty) {
- sb.append(xc.head)
- xc = xc.tail
- }
- sb.toString()
- }
-
- /** Like xs map f, but returns <code>xs</code> unchanged if function
- * <code>f</code> maps all elements to themselves.
- *
- * @param xs ...
- * @param f ...
- * @return ...
- */
- def mapConserve[A <: AnyRef](xs: List[A])(f: A => A): List[A] = {
- def loop(ys: List[A]): List[A] =
- if (ys.isEmpty) xs
- else {
- val head0 = ys.head
- val head1 = f(head0)
- if (head1 eq head0) {
- loop(ys.tail)
- } else {
- val ys1 = head1 :: mapConserve(ys.tail)(f)
- if (xs eq ys) ys1
- else {
- val b = new ListBuffer[A]
- var xc = xs
- while (xc ne ys) {
- b += xc.head
- xc = xc.tail
- }
- b.prependToList(ys1)
- }
- }
- }
- loop(xs)
- }
-
- /** Returns the list resulting from applying the given function <code>f</code>
- * to corresponding elements of the argument lists.
- *
- * @param f function to apply to each pair of elements.
- * @return <code>[f(a0,b0), ..., f(an,bn)]</code> if the lists are
- * <code>[a0, ..., ak]</code>, <code>[b0, ..., bl]</code> and
- * <code>n = min(k,l)</code>
- */
- def map2[A,B,C](xs: List[A], ys: List[B])(f: (A, B) => C): List[C] = {
- val b = new ListBuffer[C]
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- b += f(xc.head, yc.head)
- xc = xc.tail
- yc = yc.tail
- }
- b.toList
- }
-
- /** Returns the list resulting from applying the given function
- * <code>f</code> to corresponding elements of the argument lists.
- *
- * @param f function to apply to each pair of elements.
- * @return <code>[f(a<sub>0</sub>,b<sub>0</sub>,c<sub>0</sub>),
- * ..., f(a<sub>n</sub>,b<sub>n</sub>,c<sub>n</sub>)]</code>
- * if the lists are <code>[a<sub>0</sub>, ..., a<sub>k</sub>]</code>,
- * <code>[b<sub>0</sub>, ..., b<sub>l</sub>]</code>,
- * <code>[c<sub>0</sub>, ..., c<sub>m</sub>]</code> and
- * <code>n = min(k,l,m)</code>
- */
- def map3[A,B,C,D](xs: List[A], ys: List[B], zs: List[C])(f: (A, B, C) => D): List[D] = {
- val b = new ListBuffer[D]
- var xc = xs
- var yc = ys
- var zc = zs
- while (!xc.isEmpty && !yc.isEmpty && !zc.isEmpty) {
- b += f(xc.head, yc.head, zc.head)
- xc = xc.tail
- yc = yc.tail
- zc = zc.tail
- }
- b.toList
- }
-
- /** Tests whether the given predicate <code>p</code> holds
- * for all corresponding elements of the argument lists.
- *
- * @param p function to apply to each pair of elements.
- * @return <code>(p(a<sub>0</sub>,b<sub>0</sub>) &amp;&amp;
- * ... &amp;&amp; p(a<sub>n</sub>,b<sub>n</sub>))]</code>
- * if the lists are <code>[a<sub>0</sub>, ..., a<sub>k</sub>]</code>;
- * <code>[b<sub>0</sub>, ..., b<sub>l</sub>]</code>
- * and <code>n = min(k,l)</code>
- */
- def forall2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = {
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- if (!f(xc.head, yc.head)) return false
- xc = xc.tail
- yc = yc.tail
- }
- true
- }
-
- /** Tests whether the given predicate <code>p</code> holds
- * for some corresponding elements of the argument lists.
- *
- * @param p function to apply to each pair of elements.
- * @return <code>n != 0 &amp;&amp; (p(a<sub>0</sub>,b<sub>0</sub>) ||
- * ... || p(a<sub>n</sub>,b<sub>n</sub>))]</code> if the lists are
- * <code>[a<sub>0</sub>, ..., a<sub>k</sub>]</code>,
- * <code>[b<sub>0</sub>, ..., b<sub>l</sub>]</code> and
- * <code>n = min(k,l)</code>
- */
- def exists2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = {
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- if (f(xc.head, yc.head)) return true
- xc = xc.tail
- yc = yc.tail
- }
- false
- }
-
- /** Transposes a list of lists.
- * pre: All element lists have the same length.
- *
- * @param xss the list of lists
- * @return the transposed list of lists
- */
- def transpose[A](xss: List[List[A]]): List[List[A]] =
- if (xss.head.isEmpty) List()
- else (xss map (xs => xs.head)) :: transpose(xss map (xs => xs.tail))
-}
-
-/** A class representing an ordered collection of elements of type
- * <code>a</code>. This class comes with two implementing case
- * classes <code>scala.Nil</code> and <code>scala.::</code> that
- * implement the abstract members <code>isEmpty</code>,
- * <code>head</code> and <code>tail</code>.
- *
- * @author Martin Odersky and others
- * @version 1.0, 16/07/2003
- */
-sealed abstract class List[+A] extends Seq[A] {
-
- /** Returns true if the list does not contain any elements.
- * @return <code>true</code>, iff the list is empty.
- */
- override def isEmpty: Boolean
-
- /** Returns this first element of the list.
- *
- * @return the first element of this list.
- * @throws Predef.NoSuchElementException if the list is empty.
- */
- def head: A
-
- /** returns length - l, without calling length
- */
- override def lengthCompare(l: Int) = {
- if (isEmpty) 0 - l
- else if (l <= 0) 1
- else tail.lengthCompare(l - 1)
- }
-
- /** Returns this list without its first element.
- *
- * @return this list without its first element.
- * @throws Predef.NoSuchElementException if the list is empty.
- */
- def tail: List[A]
-
- /** <p>
- * Add an element <code>x</code> at the beginning of this list.
- * </p>
- *
- * @param x the element to append.
- * @return the list with <code>x</code> appended at the beginning.
- * @ex <code>1 :: List(2, 3) = List(2, 3).::(1) = List(1, 2, 3)</code>
- */
- def ::[B >: A] (x: B): List[B] =
- new scala.::(x, this)
-
- /** <p>
- * Returns a list resulting from the concatenation of the given
- * list <code>prefix</code> and this list.
- * </p>
- *
- * @param prefix the list to concatenate at the beginning of this list.
- * @return the concatenation of the two lists.
- * @ex <code>List(1, 2) ::: List(3, 4) = List(3, 4).:::(List(1, 2)) = List(1, 2, 3, 4)</code>
- */
- def :::[B >: A](prefix: List[B]): List[B] =
- if (isEmpty) prefix
- else {
- val b = new ListBuffer[B]
- var those = prefix
- while (!those.isEmpty) {
- b += those.head
- those = those.tail
- }
- b.prependToList(this)
- }
-
- /** Reverse the given prefix and append the current list to that.
- * This function is equivalent to an application of <code>reverse</code>
- * on the prefix followed by a call to <code>:::</code>, but more
- * efficient (and tail recursive).
- *
- * @param prefix the prefix to reverse and then prepend
- * @return the concatenation of the reversed prefix and the current list.
- */
- def reverse_:::[B >: A](prefix: List[B]): List[B] = {
- var these: List[B] = this
- var pres = prefix
- while (!pres.isEmpty) {
- these = pres.head :: these
- pres = pres.tail
- }
- these
- }
-
- /** Returns the number of elements in the list.
- *
- * @return the number of elements in the list.
- */
- def length: Int = {
- var these = this
- var len = 0
- while (!these.isEmpty) {
- len += 1
- these = these.tail
- }
- len
- }
-
- /** Creates a list with all indices in the list. This is
- * equivalent to a call to <code>List.range(0, xs.length)</code>.
- *
- * @return a list of all indices in the list.
- */
- def indices: List[Int] = {
- val b = new ListBuffer[Int]
- var i = 0
- var these = this
- while (!these.isEmpty) {
- b += i
- i += 1
- these = these.tail
- }
- b.toList
- }
-
- /** Returns the elements in the list as an iterator
- *
- * @return an iterator on the list elements.
- */
- override def iterator: Iterator[A] = new Iterator[A] {
- var these = List.this
- def hasNext: Boolean = !these.isEmpty
- def next: A =
- if (!hasNext)
- throw new NoSuchElementException("next on empty Iterator")
- else {
- val result = these.head; these = these.tail; result
- }
- override def toList: List[A] = these
- }
-
- /** Overrides the method in Iterable for efficiency.
- *
- * @return the list itself
- */
- override def toList: List[A] = this
-
- /** Returns the list without its last element.
- *
- * @return the list without its last element.
- * @throws Predef.UnsupportedOperationException if the list is empty.
- */
- def init: List[A] =
- if (isEmpty) throw new UnsupportedOperationException("Nil.init")
- else {
- val b = new ListBuffer[A]
- var elem = head
- var next = tail
- while (!next.isEmpty) {
- b += elem
- elem = next.head
- next = next.tail
- }
- b.toList
- }
-
- /** Returns the last element of this list.
- *
- * @return the last element of the list.
- * @throws Predef.UnsupportedOperationException if the list is empty.
- */
- override def last: A =
- if (isEmpty) throw new Predef.NoSuchElementException("Nil.last")
- else {
- var cur = this
- var next = this.tail
- while (!next.isEmpty) {
- cur = next
- next = next.tail
- }
- cur.head
- }
-
- /** Returns the <code>n</code> first elements of this list, or else the whole
- * list, if it has less than <code>n</code> elements.
- *
- * @param n the number of elements to take.
- * @return the <code>n</code> first elements of this list.
- */
- override def take(n: Int): List[A] = {
- val b = new ListBuffer[A]
- var i = 0
- var these = this
- while (!these.isEmpty && i < n) {
- i += 1
- b += these.head
- these = these.tail
- }
- if (these.isEmpty) this
- else b.toList
- }
-
- /** Returns the list with elements belonging to the given index range.
- *
- * @param start the start position of the list slice.
- * @param end the end position (exclusive) of the list slice.
- * @return the list with elements belonging to the given index range.
- */
- override def slice(start: Int, end: Int): List[A] = {
- val s = start max 0
- val e = end min this.length
- drop(s) take (e - s)
- }
-
- /** Returns the list without its <code>n</code> first elements.
- * If this list has less than <code>n</code> elements, the empty list is returned.
- *
- * @param n the number of elements to drop.
- * @return the list without its <code>n</code> first elements.
- */
- override def drop(n: Int): List[A] = {
- var these = this
- var count = n
- while (!these.isEmpty && count > 0) {
- these = these.tail
- count -= 1
- }
- these
- }
-
- /** Returns the rightmost <code>n</code> elements from this list.
- *
- * @param n the number of elements to take
- * @return the suffix of length <code>n</code> of the list
- */
- def takeRight(n: Int): List[A] = {
- def loop(lead: List[A], lag: List[A]): List[A] = lead match {
- case Nil => lag
- case _ :: tail => loop(tail, lag.tail)
- }
- loop(drop(n), this)
- }
-
- /** Returns the list wihout its rightmost <code>n</code> elements.
- *
- * @param n the number of elements to take
- * @return the suffix of length <code>n</code> of the list
- */
- def dropRight(n: Int): List[A] = {
- def loop(lead: List[A], lag: List[A]): List[A] = lead match {
- case Nil => Nil
- case _ :: tail => lag.head :: loop(tail, lag.tail)
- }
- loop(drop(n), this)
- }
-
- /** Split the list at a given point and return the two parts thus
- * created.
- *
- * @param n the position at which to split
- * @return a pair of lists composed of the first <code>n</code>
- * elements, and the other elements.
- */
- def splitAt(n: Int): (List[A], List[A]) = {
- val b = new ListBuffer[A]
- var i = 0
- var these = this
- while (!these.isEmpty && i < n) {
- i += 1
- b += these.head
- these = these.tail
- }
- (b.toList, these)
- }
-
- /** Returns the longest prefix of this list whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @return the longest prefix of this list whose elements satisfy
- * the predicate <code>p</code>.
- */
- override def takeWhile(p: A => Boolean): List[A] = {
- val b = new ListBuffer[A]
- var these = this
- while (!these.isEmpty && p(these.head)) {
- b += these.head
- these = these.tail
- }
- b.toList
- }
-
- /** Returns the longest suffix of this list whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @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
-
- /** Returns the longest prefix of the list whose elements all satisfy
- * the given predicate, and the rest of the list.
- *
- * @param p the test predicate
- * @return a pair consisting of the longest prefix of the list whose
- * elements all satisfy <code>p</code>, and the rest of the list.
- */
- def span(p: A => Boolean): (List[A], List[A]) = {
- val b = new ListBuffer[A]
- var these = this
- while (!these.isEmpty && p(these.head)) {
- b += these.head
- these = these.tail
- }
- (b.toList, these)
- }
-
- /** Like <code>span</code> but with the predicate inverted.
- */
- def break(p: A => Boolean): (List[A], List[A]) = span { x => !p(x) }
-
- /** Returns the <code>n</code>-th element of this list. The first element
- * (head of the list) is at position 0.
- *
- * @param n index of the element to return
- * @return the element at position <code>n</code> in this list.
- * @throws Predef.NoSuchElementException if the list is too short.
- */
- def apply(n: Int): A = drop(n).head
-
- /** Returns the list resulting from applying the given function <code>f</code> to each
- * element of this list.
- *
- * @param f function to apply to each element.
- * @return <code>[f(a0), ..., f(an)]</code> if this list is <code>[a0, ..., an]</code>.
- */
- final override def map[B](f: A => B): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- b += f(these.head)
- these = these.tail
- }
- b.toList
- }
-
- /** Apply a function to all the elements of the list, and return the
- * reversed list of results. This is equivalent to a call to <code>map</code>
- * followed by a call to <code>reverse</code>, but more efficient.
- *
- * @param f the function to apply to each elements.
- * @return the reversed list of results.
- */
- def reverseMap[B](f: A => B): List[B] = {
- def loop(l: List[A], res: List[B]): List[B] = l match {
- case Nil => res
- case head :: tail => loop(tail, f(head) :: res)
- }
- loop(this, Nil)
- }
-
- /** Apply the given function <code>f</code> to each element of this list
- * (while respecting the order of the elements).
- *
- * @param f the treatment to apply to each element.
- */
- final override def foreach(f: A => Unit) {
- var these = this
- while (!these.isEmpty) {
- f(these.head)
- these = these.tail
- }
- }
-
- /** Returns all the elements of this list that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- * It is guarenteed that the receiver list itself is returned iff all its
- * elements satisfy the predicate `p'. Hence the following equality is valid:
- *
- * (xs filter p) eq xs == xs forall p
- *
- * @param p the predicate used to filter the list.
- * @return the elements of this list satisfying <code>p</code>.
- */
- final override def filter(p: A => Boolean): List[A] = {
- // return same list if all elements satisfy p
- var these = this
- while (!these.isEmpty && p(these.head)) {
- these = these.tail
- }
- if (these.isEmpty) this
- else {
- val b = new ListBuffer[A]
- var these1 = this
- while (these1 ne these) {
- b += these1.head
- these1 = these1.tail
- }
-
- these = these.tail // prevent the second evaluation of the predicate
- // on the element on which it first failed
- while (!these.isEmpty) {
- if (p(these.head)) b += these.head
- these = these.tail
- }
- b.toList
- }
- }
-
-// final def filterMap[B](f: PartialFunction[A, B]): List[B] =
-// this filter f.isDefinedAt map f
-
- /** Removes all elements of the list which satisfy the predicate
- * <code>p</code>. This is like <code>filter</code> with the
- * predicate inversed.
- *
- * @param p the predicate to use to test elements
- * @return the list without all elements which satisfy <code>p</code>
- */
- def remove(p: A => Boolean): List[A] = filter (x => !p(x))
-
- /** Partition the list in two sub-lists according to a predicate.
- *
- * @param p the predicate on which to partition
- * @return a pair of lists: the list of all elements which satisfy
- * <code>p</code> and the list of all elements which do not.
- * The relative order of the elements in the sub-lists is the
- * same as in the original list.
- */
- override def partition(p: A => Boolean): (List[A], List[A]) = {
- val btrue = new ListBuffer[A]
- val bfalse = new ListBuffer[A]
- var these = this
- while (!these.isEmpty) {
- (if (p(these.head)) btrue else bfalse) += these.head
- these = these.tail
- }
- (btrue.toList, bfalse.toList)
- }
-
- /** <p>
- * Sort the list according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
- * which should be true iff <code>e1</code> is smaller than
- * <code>e2</code>.
- * </p>
- *
- * @param lt the comparison function
- * @return a list sorted according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>.
- * @ex <pre>
- * List("Steve", "Tom", "John", "Bob")
- * .sort((e1, e2) => (e1 compareTo e2) &lt; 0) =
- * List("Bob", "John", "Steve", "Tom")</pre>
- */
- def sort(lt : (A,A) => Boolean): List[A] = {
- /** Merge two already-sorted lists */
- def merge(l1: List[A], l2: List[A]): List[A] = {
- val res = new ListBuffer[A]
- var left1 = l1
- var left2 = l2
-
- while (!left1.isEmpty && !left2.isEmpty) {
- if(lt(left1.head, left2.head)) {
- res += left1.head
- left1 = left1.tail
- } else {
- res += left2.head
- left2 = left2.tail
- }
- }
-
- res ++= left1
- res ++= left2
-
- res.toList
- }
-
- /** Split a list into two lists of about the same size */
- def split(lst: List[A]) = {
- val res1 = new ListBuffer[A]
- val res2 = new ListBuffer[A]
- var left = lst
-
- while (!left.isEmpty) {
- res1 += left.head
- left = left.tail
- if (!left.isEmpty) {
- res2 += left.head
- left = left.tail
- }
- }
-
- (res1.toList, res2.toList)
- }
-
-
- /** Merge-sort the specified list */
- def ms(lst: List[A]): List[A] =
- lst match {
- case Nil => lst
- case x :: Nil => lst
- case x :: y :: Nil =>
- if (lt(x,y))
- lst
- else
- y :: x :: Nil
-
- case lst =>
- val (l1, l2) = split(lst)
- val l1s = ms(l1)
- val l2s = ms(l2)
- merge(l1s, l2s)
- }
-
- ms(this)
- }
-
-
- /** Count the number of elements in the list which satisfy a predicate.
- *
- * @param p the predicate for which to count
- * @return the number of elements satisfying the predicate <code>p</code>.
- */
- def count(p: A => Boolean): Int = {
- var cnt = 0
- var these = this
- while (!these.isEmpty) {
- if (p(these.head)) cnt += 1
- these = these.tail
- }
- cnt
- }
-
- /** Tests if the predicate <code>p</code> is satisfied by all elements
- * in this list.
- *
- * @param p the test predicate.
- * @return <code>true</code> iff all elements of this list satisfy the
- * predicate <code>p</code>.
- */
- override def forall(p: A => Boolean): Boolean = {
- var these = this
- while (!these.isEmpty) {
- if (!p(these.head)) return false
- these = these.tail
- }
- true
- }
-
- /** Tests the existence in this list of an element that satisfies the
- * predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @return <code>true</code> iff there exists an element in this list that
- * satisfies the predicate <code>p</code>.
- */
- override def exists(p: A => Boolean): Boolean = {
- var these = this
- while (!these.isEmpty) {
- if (p(these.head)) return true
- these = these.tail
- }
- false
- }
-
- /** Find and return the first element of the list satisfying a
- * predicate, if any.
- *
- * @param p the predicate
- * @return the first element in the list satisfying <code>p</code>,
- * or <code>None</code> if none exists.
- */
- override def find(p: A => Boolean): Option[A] = {
- var these = this
- while (!these.isEmpty) {
- if (p(these.head)) return Some(these.head)
- these = these.tail
- }
- None
- }
-
- /** Combines the elements of this list together using the binary
- * function <code>f</code>, from left to right, and starting with
- * the value <code>z</code>.
- *
- * @return <code>f(... (f(f(z, a<sub>0</sub>), a<sub>1</sub>) ...),
- * a<sub>n</sub>)</code> if the list is
- * <code>[a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub>]</code>.
- */
- override def foldLeft[B](z: B)(f: (B, A) => B): B = {
- var acc = z
- var these = this
- while (!these.isEmpty) {
- acc = f(acc, these.head)
- these = these.tail
- }
- acc
- }
-
- /** Combines the elements of this list together using the binary
- * function <code>f</code>, from right to left, and starting with
- * the value <code>z</code>.
- *
- * @return <code>f(a<sub>0</sub>, f(a<sub>1</sub>, f(..., f(a<sub>n</sub>, z)...)))</code>
- * if the list is <code>[a<sub>0</sub>, a1, ..., a<sub>n</sub>]</code>.
- */
- override def foldRight[B](z: B)(f: (A, B) => B): B = this match {
- case Nil => z
- case x :: xs => f(x, xs.foldRight(z)(f))
- }
-
- /** Combines the elements of this list together using the binary
- * operator <code>op</code>, from left to right
- * @param op The operator to apply
- * @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code>
- if the list has elements
- * <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
- * @throws Predef.UnsupportedOperationException if the list is empty.
- */
- override def reduceLeft[B >: A](f: (B, B) => B): B = this match {
- case Nil => throw new UnsupportedOperationException("Nil.reduceLeft")
- case x :: xs => ((xs: List[B]) foldLeft (x: B))(f)
- }
-
- /** Combines the elements of this list together using the binary
- * operator <code>op</code>, from right to left
- * @param op The operator to apply
- *
- * @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
- * if the list has elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
- * a<sub>n</sub></code>.
- *
- * @throws Predef.UnsupportedOperationException if the list is empty.
- */
- override def reduceRight[B >: A](f: (B, B) => B): B = this match {
- case Nil => throw new UnsupportedOperationException("Nil.reduceRight")
- case x :: Nil => x: B
- case x :: xs => f(x, xs reduceRight f)
- }
-
- /** Applies the given function <code>f</code> to each element of
- * this list, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this list is <code>[a<sub>0</sub>, ..., a<sub>n</sub>]</code>.
- */
- final override def flatMap[B](f: A => Iterable[B]): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- var those = f(these.head).iterator
- while (those.hasNext) {
- b += those.next
- }
- these = these.tail
- }
- b.toList
- }
-
- /** A list consisting of all elements of this list in reverse order.
- */
- override def reverse: List[A] = {
- var result: List[A] = Nil
- var these = this
- while (!these.isEmpty) {
- result = these.head :: result
- these = these.tail
- }
- result
- }
-
- /** Returns a list formed from this list and the specified list
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two lists is longer than the other, its remaining elements are ignored.
- *
- * @return <code>List((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>min(m,n)</sub>,b<sub>min(m,n)</sub>))</code> when
- * <code>List(a<sub>0</sub>, ..., a<sub>m</sub>)
- * zip List(b<sub>0</sub>, ..., b<sub>n</sub>)</code> is invoked.
- */
- def zip[B](that: List[B]): List[(A, B)] = {
- val b = new ListBuffer[(A, B)]
- var these = this
- var those = that
- while (!these.isEmpty && !those.isEmpty) {
- b += (these.head, those.head)
- these = these.tail
- those = those.tail
- }
- b.toList
- }
-
- /** Returns a list that pairs each element of this list
- * with its index, counting from 0.
- *
- * @return the list <code>List((a<sub>0</sub>,0), (a<sub>1</sub>,1), ...)</code>
- * where <code>a<sub>i</sub></code> are the elements of this list.
- */
- def zipWithIndex: List[(A, Int)] = {
- val b = new ListBuffer[(A, Int)]
- var these = this
- var idx = 0
-
- while(!these.isEmpty) {
- b += (these.head, idx)
- these = these.tail
- idx += 1
- }
-
- b.toList
- }
-
- /** Returns a list formed from this list and the specified list
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- *
- * @param that list <code>that</code> may have a different length
- * as the self list.
- * @param thisElem element <code>thisElem</code> is used to fill up the
- * resulting list if the self list is shorter than
- * <code>that</code>
- * @param thatElem element <code>thatElem</code> is used to fill up the
- * resulting list if <code>that</code> is shorter than
- * the self list
- * @return <code>List((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
- * ..., {elem,b<sub>m</sub>})</code>
- * when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
- * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
- * invoked where <code>m &gt; n</code>.
- */
- def zipAll[B, C >: A, D >: B](that: List[B], thisElem: C, thatElem: D): List[(C, D)] = {
- val b = new ListBuffer[(C, D)]
- var these = this
- var those = that
- while (!these.isEmpty && !those.isEmpty) {
- b += (these.head, those.head)
- these = these.tail
- those = those.tail
- }
- while (!these.isEmpty) {
- b += (these.head, thatElem)
- these = these.tail
- }
- while (!those.isEmpty) {
- b += (thisElem, those.head)
- those = those.tail
- }
- b.toList
- }
-
- /** Computes the union of this list and the given list
- * <code>that</code>.
- *
- * @param that the list of elements to add to the list.
- * @return a list without doubles containing the elements of this
- * list and those of the given list <code>that</code>.
- */
- def union[B >: A](that: List[B]): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- if (!that.contains(these.head)) b += these.head
- these = these.tail
- }
- b.prependToList(that)
- }
-
- /** Computes the difference between this list and the given list
- * <code>that</code>.
- *
- * @param that the list of elements to remove from this list.
- * @return this list without the elements of the given list
- * <code>that</code>.
- */
- def diff[B >: A](that: List[B]): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- if (!that.contains(these.head)) b += these.head
- these = these.tail
- }
- b.toList
- }
-
- def flatten[B](implicit f : A => Iterable[B]) : List[B] = {
- val buf = new ListBuffer[B]
- foreach(f(_).foreach(buf += _))
- buf.toList
- }
-
-
- /** Computes the intersection between this list and the given list
- * <code>that</code>.
- *
- * @param that the list to intersect.
- * @return the list of elements contained both in this list and
- * in the given list <code>that</code>.
- */
- def intersect[B >: A](that: List[B]): List[B] = filter(x => that contains x)
-
- /** Removes redundant elements from the list. Uses the method <code>==</code>
- * to decide if two elements are identical.
- *
- * @return the list without doubles.
- */
- def removeDuplicates: List[A] = {
- val b = new ListBuffer[A]
- var these = this
- while (!these.isEmpty) {
- if (!these.tail.contains(these.head)) b += these.head
- these = these.tail
- }
- b.toList
- }
-
- override protected def stringPrefix = "List"
- override def projection = toStream
- override def toStream : Stream[A] = new Stream.Definite[A] {
- override def force : List[A] = List.this
- override def isEmpty = List.this.isEmpty
- override def head = List.this.head
- override def tail = List.this.tail.toStream
- protected def addDefinedElems(buf: StringBuilder, prefix: String): StringBuilder = if (!isEmpty) {
- var prefix0 = prefix
- var buf1 = buf.append(prefix0).append(head)
- prefix0 = ", "
- var tail0 = tail
- while (!tail0.isEmpty) {
- buf1 = buf.append(prefix0).append(tail0.head)
- tail0 = tail0.tail
- }
- buf1
- } else buf
- }
-
-}
-
-/** The empty list.
- *
- * @author Martin Odersky
- * @version 1.0, 15/07/2003
- */
-@SerialVersionUID(0 - 8256821097970055419L)
-case object Nil extends List[Nothing] {
- override def isEmpty = true
- def head: Nothing =
- throw new NoSuchElementException("head of empty list")
- def tail: List[Nothing] =
- throw new NoSuchElementException("tail of empty list")
-}
-
-/** A non empty list characterized by a head and a tail.
- *
- * @author Martin Odersky
- * @version 1.0, 15/07/2003
- */
-@SerialVersionUID(0L - 8476791151983527571L)
-final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extends List[B] {
- def head : B = hd
- def tail : List[B] = tl
- override def isEmpty: Boolean = false
-}
-
diff --git a/src/cldc-library/scala/Math.scala b/src/cldc-library/scala/Math.scala
deleted file mode 100644
index 7161e0a53a..0000000000
--- a/src/cldc-library/scala/Math.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-/** The object <code>Math</code> contains methods for performing basic numeric
- * operations such as the elementary exponential, logarithm, square root, and
- * trigonometric functions.
- */
-object Math {
-
- /** The smalles possible value for scala.Byte. */
- val MIN_BYTE = java.lang.Byte.MIN_VALUE
- /** The greatest possible value for scala.Byte. */
- val MAX_BYTE = java.lang.Byte.MAX_VALUE
-
- /** The smalles possible value for scala.Short. */
- val MIN_SHORT = java.lang.Short.MIN_VALUE
- /** The greatest possible value for scala.Short. */
- val MAX_SHORT = java.lang.Short.MAX_VALUE
-
- /** The smalles possible value for scala.Char. */
- val MIN_CHAR = java.lang.Character.MIN_VALUE
- /** The greatest possible value for scala.Char. */
- val MAX_CHAR = java.lang.Character.MAX_VALUE
-
- /** The smalles possible value for scala.Int. */
- val MIN_INT = java.lang.Integer.MIN_VALUE
- /** The greatest possible value for scala.Int. */
- val MAX_INT = java.lang.Integer.MAX_VALUE
-
- /** The smalles possible value for scala.Long. */
- val MIN_LONG = java.lang.Long.MIN_VALUE
- /** The greatest possible value for scala.Long. */
- val MAX_LONG = java.lang.Long.MAX_VALUE
-
-
- def abs(x: Int): Int = java.lang.Math.abs(x)
- def abs(x: Long): Long = java.lang.Math.abs(x)
-
- def max(x: Int, y: Int): Int = java.lang.Math.max(x, y)
- def max(x: Long, y: Long): Long = java.lang.Math.max(x, y)
-
- def min(x: Int, y: Int): Int = java.lang.Math.min(x, y)
- def min(x: Long, y: Long): Long = java.lang.Math.min(x, y)
-
- def sqrt(x: Int): Int = runtime.SquareRoot.accurateSqrt(x)
-}
diff --git a/src/cldc-library/scala/Predef.scala b/src/cldc-library/scala/Predef.scala
deleted file mode 100644
index 94adbe0bde..0000000000
--- a/src/cldc-library/scala/Predef.scala
+++ /dev/null
@@ -1,188 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-
-/** The <code>Predef</code> object provides definitions that are
- * accessible in all Scala compilation units without explicit
- * qualification.
- */
-object Predef {
-
- // classOf dummy ------------------------------------------------------
-
- /** Return the runtime representation of a class type. */
- def classOf[T]: Class[T] = null
-
- // aliases ------------------------------------------------------------
-
- type byte = scala.Byte
- type short = scala.Short
- type char = scala.Char
- type int = scala.Int
- type long = scala.Long
- type boolean = scala.Boolean
- type unit = scala.Unit
-
- /** @deprecated use <code>Int</code> instead */
- @deprecated type Integer = java.lang.Integer
- /** @deprecated use <code>Char</code> instead */
- @deprecated type Character = java.lang.Character
-
- type String = java.lang.String
- type Class[T] = java.lang.Class[T]
- type Runnable = java.lang.Runnable
-
- type Throwable = java.lang.Throwable
- type Exception = java.lang.Exception
- type Error = java.lang.Error
-
- type AssertionError = java.lang.Error
- type RuntimeException = java.lang.RuntimeException
- type NullPointerException = java.lang.NullPointerException
- type ClassCastException = java.lang.ClassCastException
- type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
- type ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException
- type StringIndexOutOfBoundsException = java.lang.StringIndexOutOfBoundsException
- type UnsupportedOperationException = RuntimeException //java.lang.UnsupportedOperationException
- type IllegalArgumentException = java.lang.IllegalArgumentException
- type NoSuchElementException = java.util.NoSuchElementException
- type NumberFormatException = java.lang.NumberFormatException
-
- // miscelleaneous -----------------------------------------------------
-
- //val $scope = scala.xml.TopScope
-
- type Function[-A, +B] = Function1[A, B]
-
- type Map[A, B] = collection.immutable.Map[A, B]
- type Set[A] = collection.immutable.Set[A]
-
- val Map = collection.immutable.Map
- val Set = collection.immutable.Set
-
- // errors and asserts -------------------------------------------------
-
- def error(message: String): Nothing = throw new Error(message)
-
- def exit: Nothing = exit(0)
-
- def exit(status: Int): Nothing = {
- java.lang.System.exit(status)
- throw new Throwable()
- }
-
- def assert(assertion: Boolean) {
- if (!assertion)
- throw new AssertionError("assertion failed")
- }
-
- def assert(assertion: Boolean, message: Any) {
- if (!assertion)
- throw new AssertionError("assertion failed: " + message)
- }
-
- def assume(assumption: Boolean) {
- if (!assumption)
- throw new IllegalArgumentException("assumption failed")
- }
-
- def assume(assumption: Boolean, message: Any) {
- if (!assumption)
- throw new IllegalArgumentException("assumption failed: " + message)
- }
-
- // tupling ------------------------------------------------------------
-
- type Pair[+A, +B] = Tuple2[A, B]
- object Pair {
- def apply[A, B](x: A, y: B) = Tuple2(x, y)
- def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)
- }
-
- type Triple[+A, +B, +C] = Tuple3[A, B, C]
- object Triple {
- def apply[A, B, C](x: A, y: B, z: C) = Tuple3(x, y, z)
- def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x)
- }
-
- class ArrowAssoc[A](x: A) {
- def -> [B](y: B): Tuple2[A, B] = Tuple2(x, y)
- }
- implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x)
-
- def Tuple[A1](x1: A1) = Tuple1(x1)
- def Tuple[A1, A2](x1: A1, x2: A2) = Tuple2(x1, x2)
- def Tuple[A1, A2, A3](x1: A1, x2: A2, x3: A3) = Tuple3(x1, x2, x3)
- def Tuple[A1, A2, A3, A4](x1: A1, x2: A2, x3: A3, x4: A4) = Tuple4(x1, x2, x3, x4)
- def Tuple[A1, A2, A3, A4, A5](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5) = Tuple5(x1, x2, x3, x4, x5)
- def Tuple[A1, A2, A3, A4, A5, A6](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6) = Tuple6(x1, x2, x3, x4, x5, x6)
- def Tuple[A1, A2, A3, A4, A5, A6, A7](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6, x7: A7) = Tuple7(x1, x2, x3, x4, x5, x6, x7)
- def Tuple[A1, A2, A3, A4, A5, A6, A7, A8](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6, x7: A7, x8: A8) = Tuple8(x1, x2, x3, x4, x5, x6, x7, x8)
- def Tuple[A1, A2, A3, A4, A5, A6, A7, A8, A9](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6, x7: A7, x8: A8, x9: A9) = Tuple9(x1, x2, x3, x4, x5, x6, x7, x8, x9)
-
- // printing and reading -----------------------------------------------
-
- def print(x: Any) = Console.print(x)
- def println() = Console.println()
- def println(x: Any) = Console.println(x)
-
- // views --------------------------------------------------------------
-
- implicit def identity[A](x: A): A = x
-
- implicit def byteWrapper(x: Byte) = new runtime.RichByte(x)
- implicit def shortWrapper(x: Short) = new runtime.RichShort(x)
- implicit def intWrapper(x: Int) = new runtime.RichInt(x)
- implicit def charWrapper(c: Char) = new runtime.RichChar(c)
- implicit def longWrapper(x: Long) = new runtime.RichLong(x)
-
- 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)
-
- implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc)
-
- /** Lens from Ordering[T] to Ordered[T] */
- implicit def orderingToOrdered[T](x: T)(implicit ord: Ordering[T]): Ordered[T] =
- new Ordered[T] { def compare(that: T): Int = ord.compare(x, that) }
-
- implicit def byte2short(x: Byte): Short = x.toShort
- implicit def byte2int(x: Byte): Int = x.toInt
- implicit def byte2long(x: Byte): Long = x.toLong
-
- implicit def short2int(x: Short): Int = x.toInt
- implicit def short2long(x: Short): Long = x.toLong
-
- implicit def char2int(x: Char): Int = x.toInt
- implicit def char2long(x: Char): Long = x.toLong
-
- implicit def int2long(x: Int): Long = x.toLong
-
- implicit def byte2Byte(x: Byte) = new java.lang.Byte(x)
- implicit def short2Short(x: Short) = new java.lang.Short(x)
- implicit def char2Character(x: Char) = new java.lang.Character(x)
- implicit def int2Integer(x: Int) = new java.lang.Integer(x)
- implicit def long2Long(x: Long) = new java.lang.Long(x)
- implicit def boolean2Boolean(x: Boolean) = new java.lang.Boolean(x)
-
- /** any array projection can be automatically converted into an array */
- implicit def forceArrayProjection[A](x: Array.Projection[A]): Array[A] = x.force
- /** any random access character seq (including rich string can be converted into a string */
- implicit def forceRandomAccessCharSeq(x: runtime.RichString): String = x.mkString
-
- def currentThread = java.lang.Thread.currentThread()
-
-}
diff --git a/src/cldc-library/scala/Random.scala b/src/cldc-library/scala/Random.scala
deleted file mode 100644
index 0d14703a68..0000000000
--- a/src/cldc-library/scala/Random.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-/** (see http://java.sun.com/javame/reference/apis/jsr030/)
- *
- * @author Stephane Micheloud
- */
-class Random(val self: java.util.Random) {
-
- /** Creates a new random number generator using a single long seed. */
- def this(seed: Long) = this(new java.util.Random(seed))
-
- /** Creates a new random number generator using a single integer seed. */
- def this(seed: Int) = this(seed.toLong)
-
- /** Creates a new random number generator. */
- def this() = this(compat.Platform.currentTime)
-
- /** Returns the next pseudorandom, uniformly distributed int value
- * from this random number generator's sequence.
- */
- def nextInt(): Int = self.nextInt()
-
- /** Returns the next pseudorandom, uniformly distributed long value
- * from this random number generator's sequence.
- */
- def nextLong(): Long = self.nextLong()
-
- def setSeed(seed: Long) { self.setSeed(seed) }
-
-}
diff --git a/src/cldc-library/scala/StringBuilder.scala b/src/cldc-library/scala/StringBuilder.scala
deleted file mode 100644
index 271d9b9306..0000000000
--- a/src/cldc-library/scala/StringBuilder.scala
+++ /dev/null
@@ -1,862 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-import Predef._
-
-/** <p>
- * A mutable sequence of characters. This class provides an API compatible
- * with <code>java.lang.StringBuilder</code>, but with no guarantee of
- * synchronization.
- * </p>
- *
- * @author Stephane Micheloud
- * @version 1.0
- */
-final class StringBuilder(initCapacity: Int, private val initValue: String)
-extends (Int => Char) with Proxy {
- if (initCapacity < 0) throw new IllegalArgumentException
- if (initValue eq null) throw new NullPointerException
-
- /** The value is used for character storage. */
- private var value = new Array[Char](initCapacity + initValue.length)
-
- /** The count is the number of characters used. */
- private var count: Int = 0
-
- /** Constructs a string builder with no characters in it and an
- * initial capacity of 16 characters.
- */
- def this() = this(16, "")
-
- /** Constructs a string builder with no characters in it and an
- * initial capacity specified by the <code>capacity</code> argument.
- *
- * @param capacity the initial capacity.
- * @throws NegativeArraySizeException if the <code>capacity</code>
- * argument is less than <code>0</code>.
- */
- def this(capacity: Int) = this(capacity, "")
-
- def this(str: String) = this(16, str)
-
- append(initValue)
-
- def self = this
-
- def toArray: Array[Char] = value
-
- def length: Int = count
-
- def length_=(n: Int) { setLength(n) }
-
- /** Sets the length of the character sequence.
- *
- * @param newLength the new length
- * @throws IndexOutOfBoundsException if the <code>n</code> argument is negative.
- */
- def setLength(n: Int) {
- if (n < 0)
- throw new StringIndexOutOfBoundsException(n)
- if (n > value.length) expandCapacity(n)
- if (count < n)
- while (count < n) {
- value(count) = '\0'; count += 1
- }
- else
- count = n
- }
-
- /** Returns the current capacity. The capacity is the amount of storage
- * available for newly inserted characters, beyond which an allocation
- * will occur.
- *
- * @return the current capacity
- */
- def capacity: Int = value.length
-
- /** Same as <code>ensureCapacity</code>. */
- def capacity_=(n: Int) { ensureCapacity(n) }
-
- /** <p>
- * Ensures that the capacity is at least equal to the specified minimum.
- * If the current capacity is less than the argument, then a new internal
- * array is allocated with greater capacity. The new capacity is the larger of:
- * </p>
- * <ul>
- * <li>The <code>n</code> argument.
- * <li>Twice the old capacity, plus <code>2</code>.
- * </ul>
- * <p>
- * If the <code>n</code> argument is non-positive, this
- * method takes no action and simply returns.
- * </p>
- *
- * @param n the minimum desired capacity.
- */
- def ensureCapacity(n: Int) {
- if (n > value.length) expandCapacity(n)
- }
-
- private def expandCapacity(n: Int) {
- val newCapacity = (value.length + 1) * 2
- value = StringBuilder.copyOf(
- value,
- if (newCapacity < 0) Math.MAX_INT else if (n > newCapacity) n else newCapacity
- )
- }
-
- /** <p>
- * Returns the <code>Char</code> value in this sequence at the specified index.
- * The first <code>Char</code> value is at index <code>0</code>, the next at index
- * <code>1</code>, and so on, as in array indexing.
- * </p>
- * <p>
- * The index argument must be greater than or equal to
- * <code>0</code>, and less than the length of this sequence.
- * </p>
- *
- * @param index the index of the desired <code>Char</code> value.
- * @return the <code>Char</code> value at the specified index.
- * @throws IndexOutOfBoundsException if <code>index</code> is
- * negative or greater than or equal to <code>length()</code>.
- */
- def charAt(index: Int): Char = {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException(index)
- value(index)
- }
-
- /** Same as <code>charAt</code>. */
- def apply(i: Int): Char = charAt(i)
-
- /** <p>
- * Removes the <code>Char</code> at the specified position in this
- * sequence. This sequence is shortened by one <code>Char</code>.
- * </p>
- *
- * @param index Index of <code>Char</code> to remove
- * @return This object.
- * @throws StringIndexOutOfBoundsException if the <code>index</code>
- * is negative or greater than or equal to <code>length()</code>.
- */
- def deleteCharAt(index: Int): StringBuilder = {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException(index)
- compat.Platform.arraycopy(value, index + 1, value, index, count - index - 1)
- count -= 1
- this
- }
-
- /** <p>
- * The character at the specified index is set to <code>ch</code>. This
- * sequence is altered to represent a new character sequence that is
- * identical to the old character sequence, except that it contains the
- * character <code>ch</code> at position <code>index</code>.
- * </p>
- * <p>
- * The index argument must be greater than or equal to
- * <code>0</code>, and less than the length of this sequence.
- * </p>
- *
- * @param index the index of the character to modify.
- * @param ch the new character.
- * @throws IndexOutOfBoundsException if <code>index</code> is
- * negative or greater than or equal to <code>length()</code>.
- */
- def setCharAt(index: Int, c: Char) {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException(index)
- value(index) = c
- }
-
- /** Same as <code>setCharAt</code>. */
- def update(i: Int, c: Char) { setCharAt(i, c) }
-
- /** Returns a new <code>String</code> that contains a subsequence of
- * characters currently contained in this character sequence. The
- * substring begins at the specified index and extends to the end of
- * this sequence.
- *
- * @param start The beginning index, inclusive.
- * @return The new string.
- * @throws StringIndexOutOfBoundsException if <code>start</code> is
- * less than zero, or greater than the length of this object.
- */
- def substring(start: Int): String = substring(start, count)
-
- /** Returns a new <code>String</code> that contains a subsequence of
- * characters currently contained in this sequence. The
- * substring begins at the specified <code>start</code> and
- * extends to the character at index <code>end - 1</code>.
- *
- * @param start The beginning index, inclusive.
- * @param end The ending index, exclusive.
- * @return The new string.
- * @throws StringIndexOutOfBoundsException if <code>start</code>
- * or <code>end</code> are negative or greater than
- * <code>length()</code>, or <code>start</code> is
- * greater than <code>end</code>.
- */
- def substring(start: Int, end: Int): String = {
- if (start < 0)
- throw new StringIndexOutOfBoundsException(start)
- if (end > count)
- throw new StringIndexOutOfBoundsException(end)
- if (start > end)
- throw new StringIndexOutOfBoundsException(end - start)
- new String(value, start, end - start)
- }
-
- /** <p>
- * Appends the string representation of the <code>Any</code>
- * argument.
- * </p>
- * <p>
- * The argument is converted to a string as if by the method
- * <code>String.valueOf</code>, and the characters of that
- * string are then appended to this sequence.
- * </p>
- *
- * @param x an <code>Any</code> object.
- * @return a reference to this object.
- */
- def append(x: Any): StringBuilder =
- append(String.valueOf(x))
-
- /** Appends the specified string to this character sequence.
- *
- * @param s a string.
- * @return a reference to this object.
- */
- def append(s: String): StringBuilder = {
- val str = if (s == null) "null" else s
- val len = str.length
- if (len > 0) {
- val newCount = count + len
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(str.toCharArray, 0, value, count, len)
- count = newCount
- }
- this
- }
-
- /** Appends the specified string builder to this sequence.
- *
- * @param sb
- * @return
- */
- def append(sb: StringBuilder): StringBuilder =
- if (sb == null)
- append("null")
- else {
- val len = sb.length
- val newCount = count + len
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(sb.toArray, 0, value, count, len)
- count = newCount
- this
- }
-
- /** <p>
- * Appends the string representation of the <code>Char</code> sequence
- * argument to this sequence.
- * </p>
- * <p>
- * The characters of the sequence argument are appended, in order,
- * to the contents of this sequence. The length of this sequence
- * increases by the length of the argument.
- * </p>
- *
- * @param x the characters to be appended.
- * @return a reference to this object.
- */
- def append(x: Seq[Char]): StringBuilder =
- append(x.toArray, 0, x.length)
-
- /** <p>
- * Appends the string representation of the <code>Char</code> array
- * argument to this sequence.
- * </p>
- * <p>
- * The characters of the array argument are appended, in order, to
- * the contents of this sequence. The length of this sequence
- * increases by the length of the argument.
- * </p>
- *
- * @param x the characters to be appended.
- * @return a reference to this object.
- */
- def append(x: Array[Char]): StringBuilder =
- append(x, 0, x.length)
-
- /** <p>
- * Appends the string representation of a subarray of the
- * <code>char</code> array argument to this sequence.
- * </p>
- * <p>
- * Characters of the <code>Char</code> array <code>x</code>, starting at
- * index <code>offset</code>, are appended, in order, to the contents
- * of this sequence. The length of this sequence increases
- * by the value of <code>len</code>.
- * </p>
- *
- * @param x the characters to be appended.
- * @param offset the index of the first <code>Char</code> to append.
- * @param len the number of <code>Char</code>s to append.
- * @return a reference to this object.
- */
- def append(x: Array[Char], offset: Int, len: Int): StringBuilder = {
- val newCount = count + len
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(x, offset, value, count, len)
- count = newCount
- this
- }
-
- /** <p>
- * Appends the string representation of the <code>Boolean</code>
- * argument to the sequence.
- * </p>
- * <p>
- * The argument is converted to a string as if by the method
- * <code>String.valueOf</code>, and the characters of that
- * string are then appended to this sequence.
- * </p>
- *
- * @param x a <code>Boolean</code>.
- * @return a reference to this object.
- */
- def append(x: Boolean): StringBuilder = {
- if (x) {
- val newCount = count + 4
- if (newCount > value.length) expandCapacity(newCount)
- value(count) = 't'; count += 1
- value(count) = 'r'; count += 1
- value(count) = 'u'; count += 1
- value(count) = 'e'; count += 1
- } else {
- val newCount = count + 5
- if (newCount > value.length) expandCapacity(newCount)
- value(count) = 'f'; count += 1
- value(count) = 'a'; count += 1
- value(count) = 'l'; count += 1
- value(count) = 's'; count += 1
- value(count) = 'e'; count += 1
- }
- this
- }
-
- def append(x: Byte): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Char): StringBuilder = {
- val newCount = count + 1
- if (newCount > value.length) expandCapacity(newCount)
- value(count) = x; count += 1
- this
- }
-
- def append(x: Short): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Int): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Long): StringBuilder =
- append(String.valueOf(x))
-
- /** Removes the characters in a substring of this sequence.
- * The substring begins at the specified <code>start</code> and extends to
- * the character at index <code>end - 1</code> or to the end of the
- * sequence if no such character exists. If
- * <code>start</code> is equal to <code>end</code>, no changes are made.
- *
- * @param start The beginning index, inclusive.
- * @param end The ending index, exclusive.
- * @return This object.
- * @throws StringIndexOutOfBoundsException if <code>start</code>
- * is negative, greater than <code>length()</code>, or
- * greater than <code>end</code>.
- */
- def delete(start: Int, end: Int): StringBuilder = {
- if (start < 0 || start > end)
- throw new StringIndexOutOfBoundsException(start)
- val end0 = if (end > count) count else end
- val len = end0 - start
- if (len > 0) {
- compat.Platform.arraycopy(value, start + len, value, start, count - end0)
- count -= len
- }
- this
- }
-
- /** Replaces the characters in a substring of this sequence
- * with characters in the specified <code>String</code>. The substring
- * begins at the specified <code>start</code> and extends to the character
- * at index <code>end - 1</code> or to the end of the sequence if no such
- * character exists. First the characters in the substring are removed and
- * then the specified <code>String</code> is inserted at <code>start</code>.
- *
- * @param start The beginning index, inclusive.
- * @param end The ending index, exclusive.
- * @param str String that will replace previous contents.
- * @return This object.
- * @throws StringIndexOutOfBoundsException if <code>start</code>
- * is negative, greater than <code>length()</code>, or
- * greater than <code>end</code>.
- */
- def replace(start: Int, end: Int, str: String) {
- if (start < 0 || start > count || start > end)
- throw new StringIndexOutOfBoundsException(start)
-
- val end0 = if (end > count) count else end
- val len = str.length()
- val newCount = count + len - (end0 - start)
- if (newCount > value.length) expandCapacity(newCount)
-
- compat.Platform.arraycopy(value, end, value, start + len, count - end)
- compat.Platform.arraycopy(str.toArray, 0, value, start, len)
- count = newCount
- this
- }
-
- /** Inserts the string representation of a subarray of the <code>str</code>
- * array argument into this sequence. The subarray begins at the specified
- * <code>offset</code> and extends <code>len</code> <code>char</code>s.
- * The characters of the subarray are inserted into this sequence at
- * the position indicated by <code>index</code>. The length of this
- * sequence increases by <code>len</code> <code>Char</code>s.
- *
- * @param index position at which to insert subarray.
- * @param str a <code>Char</code> array.
- * @param offset the index of the first <code>char</code> in subarray to
- * be inserted.
- * @param len the number of <code>Char</code>s in the subarray to
- * be inserted.
- * @return This object
- * @throws StringIndexOutOfBoundsException if <code>index</code>
- * is negative or greater than <code>length()</code>, or
- * <code>offset</code> or <code>len</code> are negative, or
- * <code>(offset+len)</code> is greater than
- * <code>str.length</code>.
- */
- def insert(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder = {
- if (index < 0 || index > count)
- throw new StringIndexOutOfBoundsException(index)
- if (offset < 0 || len < 0 || offset > str.length - len)
- throw new StringIndexOutOfBoundsException(
- "offset " + offset + ", len " + len +
- ", str.length " + str.length)
- val newCount = count + len
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(value, index, value, index + len, count - index)
- compat.Platform.arraycopy(str, offset, value, index, len)
- count = newCount
- this
- }
-
- /** <p>
- * Inserts the string representation of the <code>Any</code>
- * argument into this character sequence.
- * </p>
- * <p>
- * The second argument is converted to a string as if by the method
- * <code>String.valueOf</code>, and the characters of that
- * string are then inserted into this sequence at the indicated
- * offset.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to
- * <code>0</code>, and less than or equal to the length of this
- * sequence.
- * </p>
- *
- * @param offset the offset.
- * @param x an <code>Any</code> value.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insert(at: Int, x: Any): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** Inserts the string into this character sequence.
- *
- * @param at the offset position.
- * @param x a string.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insert(at: Int, x: String): StringBuilder = {
- if (at < 0 || at > count)
- throw new StringIndexOutOfBoundsException(at)
- val str = if (x == null) "null" else x
- val len = str.length
- val newCount = count + len
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(value, at, value, at + len, count - at)
- compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, at, len)
- count = newCount
- this
- }
-
- /** Inserts the string representation of the <code>Char</code> sequence
- * argument into this sequence.
- *
- * @param at the offset position.
- * @param x a character sequence.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insert(at: Int, x: Seq[Char]): StringBuilder =
- insert(at, x.toArray)
-
- /** Inserts the string representation of the <code>Char</code> array
- * argument into this sequence.
- *
- * @param at the offset position.
- * @param x a character array.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insert(at: Int, x: Array[Char]): StringBuilder = {
- if (at < 0 || at > count)
- throw new StringIndexOutOfBoundsException(at)
- val len = x.length
- val newCount = count + len
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(value, at, value, at + len, count - at)
- compat.Platform.arraycopy(x, 0, value, at, len)
- count = newCount
- this
- }
-
- /** <p>
- * Inserts the string representation of the <code>Boolean</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Boolean</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Boolean): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Byte</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Byte</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Byte): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Char</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Char</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Char): StringBuilder = {
- if (at < 0 || at > count)
- throw new StringIndexOutOfBoundsException(at)
- val newCount = count + 1
- if (newCount > value.length) expandCapacity(newCount)
- compat.Platform.arraycopy(value, at, value, at + 1, count - at)
- value(at) = x
- count = newCount
- this
- }
-
- /** <p>
- * Inserts the string representation of the <code>Short</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Short</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Short): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Int</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Int</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Int): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Long</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Long</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Long): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Returns the index within this string of the first occurrence of the
- * specified substring. The integer returned is the smallest value
- * <i>k</i> such that:
- * </p>
- * <blockquote><pre>
- * this.toString().startsWith(str, <i>k</i>)</pre>
- * </blockquote>
- * <p>
- * is <code>true</code>.
- * </p>
- *
- * @param str any string.
- * @return if the string argument occurs as a substring within this
- * object, then the index of the first character of the first
- * such substring is returned; if it does not occur as a
- * substring, <code>-1</code> is returned.
- * @throws NullPointerException if <code>str</code> is <code>null</code>.
- */
- def indexOf(str: String): Int = indexOf(str, 0)
-
- /** <p>
- * Returns the index within this string of the first occurrence of the
- * specified substring, starting at the specified index. The integer
- * returned is the smallest value <code>k</code> for which:
- * </p><pre>
- * k >= Math.min(fromIndex, str.length()) &&
- * this.toString().startsWith(str, k)</pre>
- * <p>
- * If no such value of <code>k</code> exists, then <code>-1</code>
- * is returned.
- * </p>
- *
- * @param str the substring for which to search.
- * @param fromIndex the index from which to start the search.
- * @return the index within this string of the first occurrence
- * of the specified substring, starting at the specified index.
- */
- def indexOf(str: String, fromIndex: Int): Int =
- StringBuilder.indexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
-
- /** <p>
- * Returns the index within this string of the rightmost occurrence
- * of the specified substring. The rightmost empty string "" is
- * considered to occur at the index value <code>this.length()</code>.
- * The returned index is the largest value <i>k</i> such that
- * </p>
- * <blockquote><pre>
- * this.toString().startsWith(str, k)</pre>
- * </blockquote>
- * <p>
- * is true.
- * </p>
- *
- * @param str the substring to search for.
- * @return if the string argument occurs one or more times as a substring
- * within this object, then the index of the first character of
- * the last such substring is returned. If it does not occur as
- * a substring, <code>-1</code> is returned.
- * @throws NullPointerException if <code>str</code> is <code>null</code>.
- */
- def lastIndexOf(str: String): Int = lastIndexOf(str, count)
-
- /** <p>
- * Returns the index within this string of the last occurrence of the
- * specified substring. The integer returned is the largest value
- * <code>k</code> such that:
- * </p><pre>
- * k <= Math.min(fromIndex, str.length()) &&
- * this.toString().startsWith(str, k)</pre>
- * <p>
- * If no such value of <code>k</code> exists, then <code>-1</code>
- * is returned.
- * </p>
- *
- * @param str the substring to search for.
- * @param fromIndex the index to start the search from.
- * @return the index within this sequence of the last occurrence
- * of the specified substring.
- */
- def lastIndexOf(str: String, fromIndex: Int): Int =
- StringBuilder.lastIndexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
-
- /** <p>
- * Causes this character sequence to be replaced by the reverse of the
- * sequence. If there are any surrogate pairs included in the sequence,
- * these are treated as single characters for the reverse operation.
- * Thus, the order of the high-low surrogates is never reversed.
- * </p>
- * <p>
- * Let <i>n</i> be the character length of this character sequence
- * (not the length in <code>Char</code> values) just prior to
- * execution of the <code>reverse</code> method. Then the
- * character at index <i>k</i> in the new character sequence is
- * equal to the character at index <i>n-k-1</i> in the old
- * character sequence.
- * </p>
- *
- * @return a reference to this object.
- */
- def reverse(): StringBuilder = {
- val n = count - 1
- var j = (n-1) >> 1
- while (j >= 0) {
- val temp = value(j)
- val temp2 = value(n - j)
- value(j) = temp2
- value(n - j) = temp
- j -= 1
- }
- this
- }
-
- /** Returns a string representing the data in this sequence.
- * A new <code>String</code> object is allocated and initialized to
- * contain the character sequence currently represented by this
- * object. This <code>String</code> is then returned. Subsequent
- * changes to this sequence do not affect the contents of the
- * <code>String</code>.
- *
- * @return a string representation of this sequence of characters.
- */
- override def toString(): String = new String(value, 0, count)
-
-}
-
-
-object StringBuilder {
-
- // method <code>java.util.Arrays.copyOf</code> exists since 1.6
- private def copyOf(src: Array[Char], newLength: Int): Array[Char] = {
- val dest = new Array[Char](newLength)
- val (start, end) =
- if (src.length < newLength) (src.length, newLength)
- else (newLength, src.length)
- compat.Platform.arraycopy(src, 0, dest, 0, start)
- // For any indices that are valid in the copy but not the original,
- // the copy will contain '\\u000'.
- for (i <- start until end) dest(i) = '\0'
- dest
- }
-
- private def indexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
- target: Array[Char], targetOffset: Int, targetCount: Int,
- fromIndex: Int): Int =
- if (fromIndex >= sourceCount)
- if (targetCount == 0) sourceCount else -1
- else {
- val inx = if (fromIndex < 0) 0 else fromIndex
- if (targetCount == 0)
- inx
- else {
- val first = target(targetOffset)
- val max = sourceOffset + (sourceCount - targetCount)
-
- var i = sourceOffset + inx
- while (i <= max) {
- /* Look for first character. */
- if (source(i) != first) {
- i += 1
- while (i <= max && source(i) != first) i += 1
- }
- /* Found first character, now look at the rest of v2 */
- if (i <= max) {
- var j = i + 1
- val end = j + targetCount - 1
- var k = targetOffset + 1
- while (j < end && source(j) == target(k)) {
- j += 1
- k += 1
- }
- if (j == end) {
- /* Found whole string. */
- return i - sourceOffset
- }
- } // if
- i += 1
- } // while
- -1
- }
- }
-
- private def lastIndexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
- target: Array[Char], targetOffset: Int, targetCount: Int,
- fromIndex: Int): Int = {
- val rightIndex = sourceCount - targetCount
- if (fromIndex < 0) return -1
- val inx = if (fromIndex > rightIndex) rightIndex else fromIndex
- // Empty string always matches
- if (targetCount == 0) return inx
-
- val strLastIndex = targetOffset + targetCount - 1
- val strLastChar = target(strLastIndex)
- val min = sourceOffset + targetCount - 1
- var i = min + fromIndex
-
- while (true) {
- while (i >= min && source(i) != strLastChar) i -= 1
- if (i < min) return -1
- var j = i - 1
- val start = j - (targetCount - 1)
- var k = strLastIndex - 1
- var outerWhile = false
- while (j > start && !outerWhile) {
- if (source(j) != target(k)) {
- j -= 1
- k -= 1
- i -= 1
- outerWhile = true
- }
- }
- if (!outerWhile) return start - sourceOffset + 1
- }
- -1
- }
-}
diff --git a/src/cldc-library/scala/Symbol.scala b/src/cldc-library/scala/Symbol.scala
deleted file mode 100644
index 60010cacfe..0000000000
--- a/src/cldc-library/scala/Symbol.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala
-
-/** <p>
- * Instances of <code>Symbol</code> can be created easily with
- * Scala's built-in quote mechanism.
- * </p>
- * <p>
- * For instance, the <a href="http://scala-lang.org/" target="_top">Scala</a>
- * term <code>'mysym</code> will invoke the constructor of the
- * <code>Symbol</code> class in the following way:
- * <code>new Symbol("mysym")</code>.
- * </p>
- *
- * @author Martin Odersky
- * @version 1.7, 08/12/2003
- */
-final case class Symbol(name: String) {
-
- /** Converts this symbol to a string.
- */
- override def toString(): String = {
- "'" + name
- }
-
- /** <p>
- * Makes this symbol into a unique reference.
- * </p>
- * <p>
- * If two interened symbols are equal (i.e. they have the same name)
- * then they must be identical (wrt reference equality).
- * </p>
- *
- * @return the unique reference to this symbol.
- */
- def intern: Symbol = this
-
-}
diff --git a/src/cldc-library/scala/collection/mutable/CloneableCollection.scala b/src/cldc-library/scala/collection/mutable/CloneableCollection.scala
deleted file mode 100644
index 6dc8ed7f8e..0000000000
--- a/src/cldc-library/scala/collection/mutable/CloneableCollection.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.collection.mutable
-
-/** The J2ME version of the library defined this trait with a clone method
- * to substitute for the lack of Object.clone there
- */
-trait CloneableCollection {
- def clone(): AnyRef = Predef.error("Cloning not supported")
-}
diff --git a/src/cldc-library/scala/compat/Platform.scala b/src/cldc-library/scala/compat/Platform.scala
deleted file mode 100644
index 79b07ba0a1..0000000000
--- a/src/cldc-library/scala/compat/Platform.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.compat
-
-
-import java.lang.System
-import Predef._
-
-object Platform {
-
- //type StackOverflowError = java.lang.StackOverflowError
- type ConcurrentModificationException = java.lang.RuntimeException
-
- /**
- * @param src ..
- * @param srcPos ..
- * @param dest ..
- * @param destPos ..
- * @param length ..
- */
- def arraycopy(src: AnyRef, srcPos: Int, dest: AnyRef, destPos: Int, length: Int): Unit =
- System.arraycopy(src, srcPos, dest, destPos, length)
-
- /** Create array of the same type as arrayInstance with the given
- * length.
- *
- * @param elemClass ..
- * @param length ..
- * @return ..
- */
- def createArray(elemClass: Class[_], length: Int): AnyRef =
- throw new RuntimeException("" + elemClass + "[" + length+ "]")
- //java.lang.reflect.Array.newInstance(elemClass, length)
-
- //def arrayclear(arr: Array[Int]): Unit = java.util.Arrays.fill(arr, 0)
- def arrayclear(arr: Array[Int]): Unit = for (i <- 0 to arr.length) arr(i) = 0
-
- def getClassForName(name: String): Class[_] = java.lang.Class.forName(name)
-
- val EOL = "\n"
-
- def currentTime: Long = System.currentTimeMillis()
-
- def collectGarbage: Unit = System.gc()
-
-}
-
diff --git a/src/cldc-library/scala/runtime/BooleanRef.java b/src/cldc-library/scala/runtime/BooleanRef.java
deleted file mode 100644
index dc9b6f8ca6..0000000000
--- a/src/cldc-library/scala/runtime/BooleanRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class BooleanRef {
- public boolean elem;
- public BooleanRef(boolean elem) { this.elem = elem; }
- public String toString() { return String.valueOf(elem); }
-}
diff --git a/src/cldc-library/scala/runtime/BoxedAnyArray.scala b/src/cldc-library/scala/runtime/BoxedAnyArray.scala
deleted file mode 100644
index 751f1a1e14..0000000000
--- a/src/cldc-library/scala/runtime/BoxedAnyArray.scala
+++ /dev/null
@@ -1,234 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-import Predef._
-import compat.Platform
-
-/**
- * Arrays created by <code>new Array[T](length)</code> where <code>T</code>
- * is a type variable.
- */
-@serializable
-final class BoxedAnyArray(val length: Int) extends BoxedArray {
-
- private var boxed = new Array[AnyRef](length)
- private val hash = boxed.hashCode()
- private var unboxed: AnyRef = null
- private var elemClass: Class[_] = null
-
- def apply(index: Int): Any = synchronized {
- if (unboxed eq null)
- boxed(index);
- else if (elemClass eq classOf[Int])
- Int.box(unboxed.asInstanceOf[Array[Int]](index))
- else if (elemClass eq classOf[Long])
- Long.box(unboxed.asInstanceOf[Array[Long]](index))
- else if (elemClass eq classOf[Char])
- Char.box(unboxed.asInstanceOf[Array[Char]](index))
- else if (elemClass eq classOf[Byte])
- Byte.box(unboxed.asInstanceOf[Array[Byte]](index))
- else if (elemClass eq classOf[Short])
- Short.box(unboxed.asInstanceOf[Array[Short]](index))
- else if (elemClass eq classOf[Boolean])
- Boolean.box(unboxed.asInstanceOf[Array[Boolean]](index))
- else
- unboxed.asInstanceOf[Array[AnyRef]](index)
- }
-
- def update(index: Int, _elem: Any): Unit = synchronized {
- val elem = _elem.asInstanceOf[AnyRef]
- if (unboxed eq null)
- boxed(index) = elem
- else if (elemClass eq classOf[Int])
- unboxed.asInstanceOf[Array[Int]](index) = Int.unbox(elem)
- else if (elemClass eq classOf[Long])
- unboxed.asInstanceOf[Array[Long]](index) = Long.unbox(elem)
- else if (elemClass eq classOf[Char])
- unboxed.asInstanceOf[Array[Char]](index) = Char.unbox(elem)
- else if (elemClass eq classOf[Byte])
- unboxed.asInstanceOf[Array[Byte]](index) = Byte.unbox(elem)
- else if (elemClass eq classOf[Short])
- unboxed.asInstanceOf[Array[Short]](index) = Short.unbox(elem)
- else if (elemClass eq classOf[Boolean])
- unboxed.asInstanceOf[Array[Boolean]](index) = Boolean.unbox(elem)
- else
- unboxed.asInstanceOf[Array[AnyRef]](index) = elem
- }
-
- def unbox(elemTag: String): AnyRef =
- if (elemTag eq ScalaRunTime.IntTag) unbox(classOf[Int])
- else if (elemTag eq ScalaRunTime.LongTag) unbox(classOf[Long])
- else if (elemTag eq ScalaRunTime.CharTag) unbox(classOf[Char])
- else if (elemTag eq ScalaRunTime.ByteTag) unbox(classOf[Byte])
- else if (elemTag eq ScalaRunTime.ShortTag) unbox(classOf[Short])
- else if (elemTag eq ScalaRunTime.BooleanTag) unbox(classOf[Boolean])
- else unbox(Platform.getClassForName(elemTag))
-
- def unbox(elemClass: Class[_]): AnyRef = synchronized {
- if (unboxed eq null) {
- this.elemClass = elemClass
- if (elemClass eq classOf[Int]) {
- val newvalue = new Array[Int](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Int.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue
- } else if (elemClass eq classOf[Long]) {
- val newvalue = new Array[Long](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Long.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass eq classOf[Char]) {
- val newvalue = new Array[Char](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Char.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue
- } else if (elemClass eq classOf[Byte]) {
- val newvalue = new Array[Byte](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Byte.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue
- } else if (elemClass eq classOf[Short]) {
- val newvalue = new Array[Short](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Short.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue
- } else if (elemClass eq classOf[Boolean]) {
- val newvalue = new Array[Boolean](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Boolean.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
-// } else if (elemClass == boxed.getClass().getComponentType()) {
-// // todo: replace with ScalaRunTime.AnyRef.class
-// unboxed = boxed
- } else {
- unboxed = Platform.createArray(elemClass, length)
- Platform.arraycopy(boxed, 0, unboxed, 0, length)
- }
- boxed = null
- }
- unboxed
- }
-
- override def equals(other: Any): Boolean = (
- other.isInstanceOf[BoxedAnyArray] && (this eq (other.asInstanceOf[BoxedAnyArray])) ||
- (if (unboxed eq null) boxed == other else unboxed == other)
- )
-
- override def hashCode(): Int = hash
-
- def value: AnyRef = {
- if (unboxed eq null) throw new NotDefinedError("BoxedAnyArray.value")
- unboxed
- }
-
- private def adapt(other: AnyRef): AnyRef =
- if (this.unboxed eq null)
- other match {
- case that: BoxedAnyArray =>
- if (that.unboxed eq null) {
- that.boxed
- } else {
- if (ScalaRunTime.isValueClass(that.elemClass)) unbox(that.elemClass);
- that.unboxed
- }
- case that: BoxedArray =>
- adapt(that.value)
- case that: Array[Int] =>
- unbox(ScalaRunTime.IntTag); that
- case that: Array[Long] =>
- unbox(ScalaRunTime.LongTag); that
- case that: Array[Char] =>
- unbox(ScalaRunTime.CharTag); that
- case that: Array[Short] =>
- unbox(ScalaRunTime.ShortTag); that
- case that: Array[Byte] =>
- unbox(ScalaRunTime.ByteTag); that
- case that: Array[Boolean] =>
- unbox(ScalaRunTime.BooleanTag); that
- case _ =>
- other
- }
- else
- other match {
- case that: BoxedAnyArray =>
- if (that.unboxed ne null) that.unboxed
- else if (ScalaRunTime.isValueClass(this.elemClass)) that.unbox(this.elemClass)
- else that.boxed
- case that: BoxedArray =>
- adapt(that.value)
- case _ =>
- other
- }
-
- override def copyFrom(src: AnyRef, from: Int, to: Int, len: Int) {
- val src1 = adapt(src)
- Array.copy(src1, from, if (unboxed ne null) unboxed else boxed, to, len)
- }
-
- override def copyTo(from: Int, dest: AnyRef, to: Int, len: Int) {
- var dest1 = adapt(dest)
- Array.copy(if (unboxed ne null) unboxed else boxed, from, dest1, to, len)
- }
-
- override def subArray(start: Int, end: Int): AnyRef = {
- val result = new BoxedAnyArray(end - start);
- Array.copy(this, start, result, 0, end - start)
- result
- }
-
- final override def filter(p: Any => Boolean): BoxedArray = {
- val include = new Array[Boolean](length)
- var len = 0
- var i = 0
- while (i < length) {
- if (p(this(i))) { include(i) = true; len += 1 }
- i += 1
- }
- val result = new BoxedAnyArray(len)
- len = 0
- i = 0
- while (len < result.length) {
- if (include(i)) { result(len) = this(i); len += 1 }
- i += 1
- }
- result
- }
- override protected def newArray(length : Int, elements : Iterator[Any]) = {
- val result = new BoxedAnyArray(length)
- var i = 0
- while (elements.hasNext) {
- result(i) = elements.next
- i += 1
- }
- result
- }
-}
diff --git a/src/cldc-library/scala/runtime/BoxedObjectArray.scala b/src/cldc-library/scala/runtime/BoxedObjectArray.scala
deleted file mode 100644
index c79a3ee32a..0000000000
--- a/src/cldc-library/scala/runtime/BoxedObjectArray.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-import Predef._
-import compat.Platform.createArray
-
-@serializable
-final class BoxedObjectArray(val value: Array[AnyRef]) extends BoxedArray {
-
- def length: Int = value.length
-
- def apply(index: Int): Any = value(index)
-
- def update(index: Int, elem: Any) {
- value(index) = elem.asInstanceOf[AnyRef]
- }
-
- def unbox(elemTag: String): AnyRef = value
- def unbox(elemClass: Class[_]): AnyRef = value
-
- override def equals(other: Any): Boolean =
- value == other ||
- other.isInstanceOf[BoxedObjectArray] && value == other.asInstanceOf[BoxedObjectArray].value
-
- override def hashCode(): Int = value.hashCode()
-
- private def create(length: Int): Array[AnyRef] = {
- //createArray(value.getClass().getComponentType(), length).asInstanceOf[Array[AnyRef]]
- new Array[AnyRef](length)
- }
-
- override def subArray(start: Int, end: Int): Array[AnyRef] = {
- val result = create(end - start)
- Array.copy(value, start, result, 0, end - start)
- result
- }
-
- final override def filter(p: Any => Boolean): BoxedArray = {
- val include = new Array[Boolean](value.length)
- var len = 0
- var i = 0
- while (i < value.length) {
- if (p(value(i))) { include(i) = true; len += 1 }
- i += 1
- }
- val result = create(len)
- len = 0
- i = 0
- while (len < result.length) {
- if (include(i)) { result(len) = value(i); len += 1 }
- i += 1
- }
- new BoxedObjectArray(result)
- }
-
- override protected def newArray(length: Int, elements: Iterator[Any]) = {
- val result = create(length)
- elements.map(_.asInstanceOf[AnyRef]).copyToArray(result, 0)
- new BoxedObjectArray(result)
- }
-}
-
diff --git a/src/cldc-library/scala/runtime/BoxedUnit.java b/src/cldc-library/scala/runtime/BoxedUnit.java
deleted file mode 100644
index f8cded3e83..0000000000
--- a/src/cldc-library/scala/runtime/BoxedUnit.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public final class BoxedUnit
-{
-
- public final static BoxedUnit UNIT = new BoxedUnit();
-
- private BoxedUnit() { }
-
- public boolean equals(java.lang.Object other) {
- return this == other;
- }
-
- public int hashCode() {
- return 0;
- }
-
- public String toString() {
- return "()";
- }
-}
diff --git a/src/cldc-library/scala/runtime/BoxesRunTime.java b/src/cldc-library/scala/runtime/BoxesRunTime.java
deleted file mode 100644
index 9ab3e3c548..0000000000
--- a/src/cldc-library/scala/runtime/BoxesRunTime.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-/** An object (static class) that defines methods used for creating,
- * reverting, and calculating with, boxed values. There are four classes
- * of methods in this object:
- * - High-performance value boxing methods that feed from a pre-
- * computed map of instances for the most common instanciations.
- * - Convenience unboxing methods returning default value on null.
- * - The generalised comparison method to be used when an object may
- * be a boxed value.
- * - Standard value operators for boxed number and quasi-number values.
- *
- * @author Gilles Dubochet
- * @author Martin Odersky
- * @contributor Stepan Koltsov
- * @version 2.0 */
-public class BoxesRunTime {
-
- private static final int CHAR = 0, BYTE = 1, SHORT = 2, INT = 3, LONG = 4, OTHER = 7;
-
- private static int typeCode(Object a) {
- if (a instanceof Integer) return INT;
- if (a instanceof Character) return CHAR;
- if (a instanceof Long) return LONG;
- if (a instanceof Byte) return BYTE;
- if (a instanceof Short) return SHORT;
- return OTHER;
- }
-
-/* BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING */
-
- private static int charLowBound = 0;
- private static int charUpBound = 255;
- private static Character[] charCache = new Character[charUpBound - charLowBound + 1];
-
- private static int byteLowBound = -128;
- private static int byteUpBound = 127;
- private static Byte[] byteCache = new Byte[byteUpBound - byteLowBound + 1];
-
- private static int shortLowBound = -128;
- private static int shortUpBound = 127;
- private static Short[] shortCache = new Short[shortUpBound - shortLowBound + 1];
-
- private static int intLowBound = -128;
- private static int intUpBound = 1024;
- private static Integer[] intCache = new Integer[intUpBound - intLowBound + 1];
-
- private static int longLowBound = -128;
- private static int longUpBound = 1024;
- private static Long[] longCache = new Long[longUpBound - longLowBound + 1];
-
- static {
- int idx = 0;
- while (idx <= charUpBound - charLowBound) {
- charCache[idx] = new Character((char)(idx + charLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= byteUpBound - byteLowBound) {
- byteCache[idx] = new Byte((byte)(idx + byteLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= shortUpBound - shortLowBound) {
- shortCache[idx] = new Short((short)(idx + shortLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= intUpBound - intLowBound) {
- intCache[idx] = new Integer((int)(idx + intLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= longUpBound - longLowBound) {
- longCache[idx] = new Long((long)(idx + longLowBound));
- idx = idx + 1;
- }
- }
-
- private static final Boolean TRUE = new Boolean(true);
- private static final Boolean FALSE = new Boolean(false);
- public static Boolean boxToBoolean(boolean b) {
- return b ? TRUE : FALSE;
- }
-
- public static Character boxToCharacter(char c) {
- if (c >= charLowBound && c <= charUpBound)
- return charCache[(int)c - charLowBound];
- return new Character(c);
- }
-
- public static Byte boxToByte(byte b) {
- if (b >= byteLowBound && b <= byteUpBound)
- return byteCache[(int)b - byteLowBound];
- return new Byte(b);
- }
-
- public static Short boxToShort(short s) {
- if (s >= shortLowBound && s <= shortUpBound)
- return shortCache[(int)s - shortLowBound];
- return new Short(s);
- }
-
- public static Integer boxToInteger(int i) {
- if (i >= intLowBound && i <= intUpBound)
- return intCache[(int)i - intLowBound];
- return new Integer(i);
- }
-
- public static Long boxToLong(long l) {
- if (l >= longLowBound && l <= longUpBound)
- return longCache[(int)l - longLowBound];
- return new Long(l);
- }
-
-/* UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING */
-
- public static boolean unboxToBoolean(Object b) {
- return b == null ? false : ((Boolean)b).booleanValue();
- }
-
- public static char unboxToChar(Object c) {
- return c == null ? 0 : ((Character)c).charValue();
- }
-
- public static byte unboxToByte(Object b) {
- return b == null ? 0 : ((Byte)b).byteValue();
- }
-
- public static short unboxToShort(Object s) {
- return s == null ? 0 : ((Short)s).shortValue();
- }
-
- public static int unboxToInt(Object i) {
- return i == null ? 0 : ((Integer)i).intValue();
- }
-
- public static long unboxToLong(Object l) {
- return l == null ? 0 : ((Long)l).longValue();
- }
-
- /*
- public static boolean unboxToBoolean(Object b) {
- if (b == null)
- throw new ClassCastException("null is no Boolean value");
- return ((Boolean)b).booleanValue();
- }
-
- public static char unboxToChar(Object c) {
- if (c == null)
- throw new ClassCastException("null is no Char value");
- return ((Character)c).charValue();
- }
-
- public static byte unboxToByte(Object b) {
- if (b == null)
- throw new ClassCastException("null is no Byte value");
- return ((Byte)b).byteValue();
- }
-
- public static short unboxToShort(Object s) {
- if (s == null)
- throw new ClassCastException("null is no Short value");
- return ((Short)s).shortValue();
- }
-
- public static int unboxToInt(Object i) {
- if (i == null)
- throw new ClassCastException("null is no Int value");
- return ((Integer)i).intValue();
- }
-
- public static long unboxToLong(Object l) {
- if (l == null)
- throw new ClassCastException("null is no Long value");
- return ((Long)l).longValue();
- }
- */
-
-/* COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON */
-
- /** A rich implementation of the <code>equals</code> method that overrides the
- * default equals because Java's boxed primitives are utterly broken. This equals
- * is inserted instead of a normal equals by the Scala compiler (in the
- * ICode phase, method <code>genEqEqPrimitive</code>) only when either
- * side of the comparison is a subclass of <code>AnyVal</code>, of
- * <code>java.lang.Number</code>, of <code>java.lang.Character</code> or
- * is exactly <code>Any</code> or <code>AnyRef</code>. */
- public static boolean equals(Object a, Object b) {
- if (a == null)
- return b == null;
- if (b == null)
- return false;
- if (a.equals(b))
- return true;
-
- final long left =
- (a instanceof Integer) ? ((Integer)a).intValue() :
- (a instanceof Character) ? ((Character)a).charValue() :
- (a instanceof Long) ? ((Long)a).longValue() :
- (a instanceof Byte) ? ((Byte)a).byteValue() :
- ((Short)a).shortValue();
-
- final long right =
- (b instanceof Integer) ? ((Integer)b).intValue() :
- (b instanceof Character) ? ((Character)b).charValue() :
- (b instanceof Long) ? ((Long)b).longValue() :
- (b instanceof Byte) ? ((Byte)b).byteValue() :
- ((Short)b).shortValue();
-
- return left == right;
- }
-
-/* OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS */
-
- /** arg1 + arg2 */
- public static Object add(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 - arg2 */
- public static Object subtract(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 * arg2 */
- public static Object multiply(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 / arg2 */
- public static Object divide(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 % arg2 */
- public static Object takeModulo(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 >> arg2 */
- public static Object shiftSignedRight(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 << arg2 */
- public static Object shiftSignedLeft(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 >>> arg2 */
- public static Object shiftLogicalRight(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** -arg */
- public static Object negate(Object arg) throws Error {
- throw new Error();
- }
-
- /** +arg */
- public static Object positive(Object arg) throws Error {
- throw new Error();
- }
-
- /** arg1 & arg2 */
- public static Object takeAnd(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 | arg2 */
- public static Object takeOr(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 ^ arg2 */
- public static Object takeXor(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 && arg2 */
- public static Object takeConditionalAnd(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg1 || arg2 */
- public static Object takeConditionalOr(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** ~arg */
- public static Object complement(Object arg) throws Error {
- throw new Error();
- }
-
- /** !arg */
- public static Object takeNot(Object arg) throws Error {
- throw new Error();
- }
-
- public static Object testEqual(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- public static Object testNotEqual(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- public static Object testLessThan(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- public static Object testLessOrEqualThan(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- public static Object testGreaterOrEqualThan(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- public static Object testGreaterThan(Object arg1, Object arg2) throws Error {
- throw new Error();
- }
-
- /** arg.toChar */
- public static Character toCharacter(Object arg) throws Error {
- throw new Error();
- }
-
- /** arg.toByte */
- public static Byte toByte(Object arg) throws Error {
- throw new Error();
- }
-
- /** arg.toShort */
- public static Short toShort(Object arg) throws Error {
- throw new Error();
- }
-
- /** arg.toInt */
- public static Integer toInteger(Object arg) throws Error {
- throw new Error();
- }
-
- /** arg.toLong */
- public static Long toLong(Object arg) throws Error {
- throw new Error();
- }
-
-}
diff --git a/src/cldc-library/scala/runtime/BoxesUtility.java b/src/cldc-library/scala/runtime/BoxesUtility.java
deleted file mode 100644
index 6ebc7e4d14..0000000000
--- a/src/cldc-library/scala/runtime/BoxesUtility.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-/**
- * @author Gilles Dubochet
- * @version 1.0
- */
-public class BoxesUtility {
-
- private static int charLowBound = 0;
- private static int charUpBound = 255;
- private static Character[] charCache = new Character[charUpBound - charLowBound + 1];
-
- private static int byteLowBound = -128;
- private static int byteUpBound = 127;
- private static Byte[] byteCache = new Byte[byteUpBound - byteLowBound + 1];
-
- private static int shortLowBound = -128;
- private static int shortUpBound = 127;
- private static Short[] shortCache = new Short[shortUpBound - shortLowBound + 1];
-
- private static int intLowBound = -128;
- private static int intUpBound = 1024;
- private static Integer[] intCache = new Integer[intUpBound - intLowBound + 1];
-
- private static int longLowBound = -128;
- private static int longUpBound = 1024;
- private static Long[] longCache = new Long[longUpBound - longLowBound + 1];
-
- static {
- int idx = 0;
- while (idx <= charUpBound - charLowBound) {
- charCache[idx] = new Character((char)(idx + charLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= byteUpBound - byteLowBound) {
- byteCache[idx] = new Byte((byte)(idx + byteLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= shortUpBound - shortLowBound) {
- shortCache[idx] = new Short((short)(idx + shortLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= intUpBound - intLowBound) {
- intCache[idx] = new Integer((int)(idx + intLowBound));
- idx = idx + 1;
- }
- idx = 0;
- while (idx <= longUpBound - longLowBound) {
- longCache[idx] = new Long((long)(idx + longLowBound));
- idx = idx + 1;
- }
- }
- private static final Boolean TRUE = new Boolean(true);
- private static final Boolean FALSE = new Boolean(false);
- public static Boolean boxToBoolean(boolean b) {
- return b ? TRUE : FALSE;
- }
-
- public static Character boxToCharacter(char c) {
- if (c >= charLowBound && c <= charUpBound)
- return charCache[(int)c - charLowBound];
- else
- return new Character(c);
- }
-
- public static Byte boxToByte(byte b) {
- if (b >= byteLowBound && b <= byteUpBound)
- return byteCache[(int)b - byteLowBound];
- else
- return new Byte(b);
- }
-
- public static Short boxToShort(short s) {
- if (s >= shortLowBound && s <= shortUpBound)
- return shortCache[(int)s - shortLowBound];
- else
- return new Short(s);
- }
-
- public static Integer boxToInteger(int i) {
- if (i >= intLowBound && i <= intUpBound)
- return intCache[(int)i - intLowBound];
- else
- return new Integer(i);
- }
-
- public static Long boxToLong(long l) {
- if (l >= longLowBound && l <= longUpBound)
- return longCache[(int)l - longLowBound];
- else
- return new Long(l);
- }
-
- public static boolean unboxToBoolean(Object b) {
- return b == null ? false : ((Boolean)b).booleanValue();
- }
-
- public static char unboxToChar(Object c) {
- if (c == null)
- return 0;
- else
- return ((Character)c).charValue();
- }
-
- public static byte unboxToByte(Object b) {
- if (b == null)
- return 0;
- else
- return ((Byte)b).byteValue();
- }
-
- public static short unboxToShort(Object s) {
- if (s == null)
- return 0;
- else
- return ((Short)s).shortValue();
- }
-
- public static int unboxToInt(Object i) {
- if (i == null)
- return 0;
- else
- return ((Integer)i).intValue();
- }
-
- public static long unboxToLong(Object l) {
- if (l == null)
- return 0;
- else
- return ((Long)l).longValue();
- }
-
-}
diff --git a/src/cldc-library/scala/runtime/ByteRef.java b/src/cldc-library/scala/runtime/ByteRef.java
deleted file mode 100644
index 1704d92f8a..0000000000
--- a/src/cldc-library/scala/runtime/ByteRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class ByteRef {
- public byte elem;
- public ByteRef(byte elem) { this.elem = elem; }
- public String toString() { return String.valueOf(elem); }
-}
diff --git a/src/cldc-library/scala/runtime/CharRef.java b/src/cldc-library/scala/runtime/CharRef.java
deleted file mode 100644
index 7100978b62..0000000000
--- a/src/cldc-library/scala/runtime/CharRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class CharRef {
- public char elem;
- public CharRef(char elem) { this.elem = elem; }
- public String toString() { return String.valueOf(elem); }
-}
diff --git a/src/cldc-library/scala/runtime/Comparator.java b/src/cldc-library/scala/runtime/Comparator.java
deleted file mode 100644
index 0e6f8ecff7..0000000000
--- a/src/cldc-library/scala/runtime/Comparator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-/**
- * @author Gilles Dubochet
- * @author Martin Odersky
- * @version 1.2 */
-public class Comparator {
-
- /** A rich implementation of the equals method that overrides the default
- * equals because Java's boxed primitives are utterly broken. This equals
- * is inserted instead of a normal equals by the Scala compiler (in the
- * ICode phase, method <code>genEqEqPrimitive</code>) only when either
- * side of the comparison is a subclass of <code>AnyVal</code>, of
- * <code>java.lang.Number</code>, of <code>java.lang.Character</code> or
- * is exactly <code>Any</code> or <code>AnyRef</code>, but when both sides
- * have different types. */
- public static boolean equals(Object a, Object b) {
- if (a == null)
- return b == null;
- if (b == null)
- return false;
- if (a.equals(b))
- return true;
-
- final long left =
- (a instanceof Integer) ? ((Integer)a).intValue() :
- (a instanceof Character) ? ((Character)a).charValue() :
- (a instanceof Long) ? ((Long)a).longValue() :
- (a instanceof Byte) ? ((Byte)a).byteValue() :
- ((Short)a).shortValue();
-
- final long right =
- (b instanceof Integer) ? ((Integer)b).intValue() :
- (b instanceof Character) ? ((Character)b).charValue() :
- (b instanceof Long) ? ((Long)b).longValue() :
- (b instanceof Byte) ? ((Byte)b).byteValue() :
- ((Short)b).shortValue();
-
- return left == right;
- }
-
-}
diff --git a/src/cldc-library/scala/runtime/IntRef.java b/src/cldc-library/scala/runtime/IntRef.java
deleted file mode 100644
index 47e7eb9411..0000000000
--- a/src/cldc-library/scala/runtime/IntRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class IntRef {
- public int elem;
- public IntRef(int elem) { this.elem = elem; }
- public String toString() { return String.valueOf(elem); }
-}
diff --git a/src/cldc-library/scala/runtime/LongRef.java b/src/cldc-library/scala/runtime/LongRef.java
deleted file mode 100644
index 80972014c3..0000000000
--- a/src/cldc-library/scala/runtime/LongRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class LongRef {
- public long elem;
- public LongRef(long elem) { this.elem = elem; }
- public String toString() { return String.valueOf(elem); }
-}
diff --git a/src/cldc-library/scala/runtime/ObjectRef.java b/src/cldc-library/scala/runtime/ObjectRef.java
deleted file mode 100644
index 9d7aa0998c..0000000000
--- a/src/cldc-library/scala/runtime/ObjectRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class ObjectRef {
- public Object elem;
- public ObjectRef(Object elem) { this.elem = elem; }
- public String toString() { return "" + elem; }
-}
diff --git a/src/cldc-library/scala/runtime/RichChar.scala b/src/cldc-library/scala/runtime/RichChar.scala
deleted file mode 100644
index 019c01ede2..0000000000
--- a/src/cldc-library/scala/runtime/RichChar.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-import java.lang.Character
-import Predef.NoSuchElementException
-
-/** <p>
- * For example, in the following code
- * </p>
- * <pre>
- * <b>object</b> test <b>extends</b> Application {
- * Console.println(<chr>'\40'</chr>.isWhitespace)
- * Console.println('\011'.isWhitespace)
- * Console.println('1'.asDigit == 1)
- * Console.println('A'.asDigit == 10)
- * }</pre>
- * <p>
- * the implicit conversions are performed using the predefined view
- * <a href="../Predef$object.html#charWrapper(scala.Char)"
- * target="contentFrame"><code>Predef.charWrapper</code></a>.
- * </p>
- */
-final class RichChar(x: Char) extends Proxy with Ordered[Char] {
-
- // Proxy.self
- def self: Any = x
-
- // Ordered[Char].compare
- def compare (y: Char): Int = if (x < y) -1 else if (x > y) 1 else 0
-
- def asDigit: Int = Character.digit(x, Character.MAX_RADIX)
-
- //def isControl: Boolean = Character.isISOControl(x)
- def isDigit: Boolean = Character.isDigit(x)
- //def isLetter: Boolean = Character.isLetter(x)
- //def isLetterOrDigit: Boolean = Character.isLetterOrDigit(x)
- def isLowerCase: Boolean = Character.isLowerCase(x)
- def isUpperCase: Boolean = Character.isUpperCase(x)
- //def isWhitespace: Boolean = Character.isWhitespace(x)
-
- def toLowerCase: Char = Character.toLowerCase(x)
- def toUpperCase: Char = Character.toUpperCase(x)
-
- /** Create an Iterator[Char] over the characters from 'x' to 'y' - 1
- */
- def until(limit: Char): Iterator[Char] = new Iterator[Char] {
- private var ch = x
- def hasNext: Boolean = ch < limit
- def next: Char =
- if (hasNext) { val j = ch; ch = (ch + 1).toChar; j }
- else throw new NoSuchElementException("next on empty iterator")
- }
-
- //def until(y: Char): Iterator[Char] = to(y)
-
- /** Create an Iterator[Char] over the characters from 'x' to 'y'
- */
- def to(y: Char): Iterator[Char] = until((y + 1).toChar)
-
-}
diff --git a/src/cldc-library/scala/runtime/RichException.scala b/src/cldc-library/scala/runtime/RichException.scala
deleted file mode 100644
index 7f0df60417..0000000000
--- a/src/cldc-library/scala/runtime/RichException.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id
-
-
-package scala.runtime
-
-import Predef._
-import compat.Platform.EOL
-
-final class RichException(exc: Throwable) {
-
- def getStackTraceString: String = {
- throw new UnsupportedOperationException(exc.toString)
-// val s = new StringBuilder()
-// for (trElem <- exc.getStackTrace()) {
-// s.append(trElem.toString())
-// s.append(EOL)
-// }
-// s.toString()
- }
-
-}
diff --git a/src/cldc-library/scala/runtime/RichLong.scala b/src/cldc-library/scala/runtime/RichLong.scala
deleted file mode 100644
index 7c3a13c912..0000000000
--- a/src/cldc-library/scala/runtime/RichLong.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-final class RichLong(x: Long) extends Proxy with Ordered[Long] {
-
- // Proxy.self
- def self: Any = x
-
- // Ordered[Long].compare
- def compare(y: Long): Int = if (x < y) -1 else if (x > y) 1 else 0
-
- def min(y: Long): Long = if (x < y) x else y
- def max(y: Long): Long = if (x > y) x else y
- def abs: Long = if (x < 0) -x else x
-
- def toBinaryString: String = java.lang.Long.toString(x, 2)
- def toHexString: String = java.lang.Long.toString(x, 16)
- def toOctalString: String = java.lang.Long.toString(x, 8)
-}
diff --git a/src/cldc-library/scala/runtime/RichString.scala b/src/cldc-library/scala/runtime/RichString.scala
deleted file mode 100644
index 2a2dd85410..0000000000
--- a/src/cldc-library/scala/runtime/RichString.scala
+++ /dev/null
@@ -1,219 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-import Predef._
-
-final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char] with Ordered[String] {
- import RichString._
- 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 len = self.length
- new RichString(
- if (from >= until || from >= len)
- ""
- else {
- val from0 = if (from < 0) 0 else from
- val until0 = if (until > len) len else until
- 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 reverse: RichString = {
- val buf = new StringBuilder
- var i = self.length - 1
- while (i >= 0) {
- buf append (self charAt i)
- i -= 1
- }
- new RichString(buf.toString)
- }
-
- override def compare(other: String) = self compareTo other
-
- private def isLineBreak(c: Char) = c == LF || c == FF
-
- /** <p>
- * Strip trailing line end character from this string if it has one.
- * A line end character is one of
- * </p>
- * <ul style="list-style-type: none;">
- * <li>LF - line feed (0x0A hex)</li>
- * <li>FF - form feed (0x0C hex)</li>
- * </ul>
- * <p>
- * If a line feed character LF is preceded by a carriage return CR
- * (0x0D hex), the CR character is also stripped (Windows convention).
- * </p>
- */
- def stripLineEnd: String = {
- val len = self.length
- if (len == 0) self
- else {
- val last = apply(len - 1)
- if (isLineBreak(last))
- self.substring(0, if (last == LF && len >= 2 && apply(len - 2) == CR) len - 2 else len - 1)
- else
- self
- }
- }
-
- /** <p>
- * Return all lines in this string in an iterator, including trailing
- * line end characters.
- * </p>
- * <p>
- * The number of strings returned is one greater than the number of line
- * end characters in this string. For an empty string, a single empty
- * line is returned. A line end character is one of
- * </p>
- * <ul style="list-style-type: none;">
- * <li>LF - line feed (0x0A hex)</li>
- * <li>FF - form feed (0x0C hex)</li>
- * </ul>
- */
- def linesWithSeparators = new Iterator[String] {
- val len = self.length
- var index = 0
- def hasNext: Boolean = index < len
- def next(): String = {
- if (index >= len) throw new NoSuchElementException("next on empty iterator")
- val start = index
- while (index < len && !isLineBreak(apply(index))) index += 1
- index += 1
- self.substring(start, index min len)
- }
- }
-
- /** Return all lines in this string in an iterator, excluding trailing line
- * end characters, i.e. apply <code>.stripLineEnd</code> to all lines
- * returned by <code>linesWithSeparators</code>.
- */
- def lines: Iterator[String] =
- linesWithSeparators map (line => new RichString(line).stripLineEnd)
-
- /** Returns this string with first character converted to upper case */
- def capitalize: String =
- if (self == null) null
- else if (self.length == 0) ""
- else {
- val chars = self.toCharArray
- chars(0) = chars(0).toUpperCase
- new String(chars)
- }
-
- /** <p>
- * For every line in this string:
- * </p>
- * <blockquote>
- * Strip a leading prefix consisting of blanks or control characters
- * followed by <code>marginChar</code> from the line.
- * </blockquote>
- */
- def stripMargin(marginChar: Char): String = {
- val buf = new StringBuilder()
- for (line <- linesWithSeparators) {
- val len = line.length
- var index = 0
- while (index < len && line.charAt(index) <= ' ') index += 1
- buf append
- (if (index < len && line.charAt(index) == marginChar) line.substring(index + 1) else line)
- }
- buf.toString
- }
-
- /** <p>
- * For every line in this string:
- * </p>
- * <blockquote>
- * Strip a leading prefix consisting of blanks or control characters
- * followed by <code>|</code> from the line.
- * </blockquote>
- */
- def stripMargin: String = stripMargin('|')
-/*
- private def escape(ch: Char): String = ch match {
- case '.' | '$' | '^' | '\\' => "\\" + ch
- case _ => "" + ch
- }
-
- @throws(classOf[java.util.regex.PatternSyntaxException])
- def split(separator: Char): Array[String] = self.split(escape(separator))
-
- @throws(classOf[java.util.regex.PatternSyntaxException])
- def split(separators: Array[Char]): Array[String] = {
- val re = separators.foldLeft("[")(_+_) + "]"
- self.split(re)
- }
-*/
- def toBoolean: Boolean = parseBoolean(self)
- def toByte: Byte = java.lang.Byte.parseByte(self)
- def toShort: Short = java.lang.Short.parseShort(self)
- def toInt: Int = java.lang.Integer.parseInt(self)
- def toLong: Long = java.lang.Long.parseLong(self)
- //def toFloat: Float = java.lang.Float.parseFloat(self)
- //def toDouble: Double = java.lang.Double.parseDouble(self)
-}
-
-object RichString {
- // just statics for rich string.
- private final val LF: Char = 0x0A
- private final val FF: Char = 0x0C
- private final val CR: Char = 0x0D
- private final val SU: Char = 0x1A
-
- private def parseBoolean(s: String): Boolean =
- if (s != null) s.toLowerCase match {
- case "true" => true
- case "false" => false
- case _ => throw new NumberFormatException("For input string: \""+s+"\"")
- }
- else
- throw new NumberFormatException("For input string: \"null\"")
-}
-
diff --git a/src/cldc-library/scala/runtime/ScalaRunTime.scala b/src/cldc-library/scala/runtime/ScalaRunTime.scala
deleted file mode 100644
index af6739de7d..0000000000
--- a/src/cldc-library/scala/runtime/ScalaRunTime.scala
+++ /dev/null
@@ -1,142 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-import Predef._
-
-/* The object <code>ScalaRunTime</code> provides ...
- */
-object ScalaRunTime {
-
- /** Names for primitive types, used by array unboxing */
- val ByteTag = ".Byte"
- val ShortTag = ".Short"
- val CharTag = ".Char"
- val IntTag = ".Int"
- val LongTag = ".Long"
- val BooleanTag = ".Boolean"
-
- def isArray(x: AnyRef): Boolean =
- (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray])
-
- def isValueTag(tag: String) = tag.charAt(0) == '.'
-
- def isValueClass(clazz: Class[_]) =
- clazz == classOf[Boolean] || clazz == classOf[Byte] ||
- clazz == classOf[Short ] || clazz == classOf[Char] ||
- clazz == classOf[Int ] || clazz == classOf[Long]
-
- def checkInitialized[T <: AnyRef](x: T): T =
- if (x == null) throw new UninitializedError else x
-
- abstract class Try[A] {
- def Catch[B >: A](handler: PartialFunction[Throwable, B]): B
- def Finally(handler: Unit): A
- }
-
- def Try[A](block: => A): Try[A] = new Try[A] with Runnable {
- var result: A = _
- var exception: Throwable = ExceptionHandling.tryCatch(this)
-
- def run() { result = block }
-
- def Catch[B >: A](handler: PartialFunction[Throwable, B]): B =
- if (exception eq null)
- result.asInstanceOf[B]
- // !!! else if (exception is LocalReturn)
- // !!! // ...
- else if (handler isDefinedAt exception)
- handler(exception)
- else
- throw exception
-
- def Finally(handler: Unit): A =
- if (exception eq null)
- result.asInstanceOf[A]
- else
- throw exception
- }
-
- def caseFields(x: Product): List[Any] = {
- val arity = x.productArity
- def fields(from: Int): List[Any] =
- if (from == arity) List()
- else x.productElement(from) :: fields(from + 1)
- fields(0)
- }
-
- def _toString(x: Product): String =
- caseFields(x).mkString(x.productPrefix + "(", ",", ")")
-
- def _hashCode(x: Product): Int = {
- var code = x.getClass().hashCode()
- val arr = x.productArity
- var i = 0
- while (i < arr) {
- code = code * 41 + x.productElement(i).hashCode()
- i += 1
- }
- code
- }
-
- def _equals(x: Product, y: Any): Boolean = y match {
- case y1: Product if x.productArity == y1.productArity =>
- val arity = x.productArity
- var i = 0
- while (i < arity && x.productElement(i) == y1.productElement(i))
- i += 1
- i == arity
- case _ =>
- false
- }
-
- def _equalsWithVarArgs(x: Product, y: Any): Boolean = y match {
- case y1: Product if x.productArity == y1.productArity =>
- val arity = x.productArity
- var i = 0
- while (i < arity - 1 && x.productElement(i) == y1.productElement(i))
- i += 1
- i == arity - 1 && {
- x.productElement(i) match {
- case xs: Seq[_] =>
- y1.productElement(i) match {
- case ys: Seq[_] => xs sameElements ys
- }
- }
- }
- case _ =>
- false
- }
-
- //def checkDefined[T >: Null](x: T): T =
- // if (x == null) throw new UndefinedException else x
-
- def Seq[A](xs: A*): Seq[A] = null // interpreted specially by new backend.
-
- def arrayValue(x: BoxedArray, elemTag: String): AnyRef =
- if (x eq null) null else x.unbox(elemTag)
-
- def arrayValue(x: BoxedArray, elemClass: Class[_]): AnyRef =
- if (x eq null) null else x.unbox(elemClass)
-
- def boxArray(value: AnyRef): BoxedArray = value match {
- case x: Array[Byte] => new BoxedByteArray(x)
- case x: Array[Short] => new BoxedShortArray(x)
- case x: Array[Char] => new BoxedCharArray(x)
- case x: Array[Int] => new BoxedIntArray(x)
- case x: Array[Long] => new BoxedLongArray(x)
- case x: Array[Boolean] => new BoxedBooleanArray(x)
- case x: Array[AnyRef] => new BoxedObjectArray(x)
- case x: BoxedArray => x
- }
-}
diff --git a/src/cldc-library/scala/runtime/ShortRef.java b/src/cldc-library/scala/runtime/ShortRef.java
deleted file mode 100644
index ae689c044f..0000000000
--- a/src/cldc-library/scala/runtime/ShortRef.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime;
-
-
-public class ShortRef {
- public short elem;
- public ShortRef(short elem) { this.elem = elem; }
- public String toString() { return String.valueOf(elem); }
-}
diff --git a/src/cldc-library/scala/runtime/SquareRoot.scala b/src/cldc-library/scala/runtime/SquareRoot.scala
deleted file mode 100644
index f6b593f7c6..0000000000
--- a/src/cldc-library/scala/runtime/SquareRoot.scala
+++ /dev/null
@@ -1,151 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-import Predef._
-
-/**
- * <p>
- * Integer Square Root function (see http://atoms.alife.co.uk/sqrt/index.html).
- * </p>
- * <p>
- * Contributors include Arne Steinarson for the basic approximation idea, Dann
- * Corbit and Mathew Hendry for the first cut at the algorithm, Lawrence Kirby
- * for the rearrangement, improvments and range optimization, Paul Hsieh
- * for the round-then-adjust idea, Tim Tyler, for the Java port
- * and Jeff Lawson for a bug-fix and some code to improve accuracy.
- * </p>
- *
- * @version v0.02 - 2003/09/07
- */
-
-/**
- * Faster replacements for <code>(int)(java.lang.Math.sqrt(integer))</code>
- */
-object SquareRoot {
- private val table = Array(
- 0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57,
- 59, 61, 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 81, 83,
- 84, 86, 87, 89, 90, 91, 93, 94, 96, 97, 98, 99, 101, 102,
- 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118,
- 119, 120, 121, 122, 123, 124, 125, 126, 128, 128, 129, 130, 131, 132,
- 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 144, 145,
- 146, 147, 148, 149, 150, 150, 151, 152, 153, 154, 155, 155, 156, 157,
- 158, 159, 160, 160, 161, 162, 163, 163, 164, 165, 166, 167, 167, 168,
- 169, 170, 170, 171, 172, 173, 173, 174, 175, 176, 176, 177, 178, 178,
- 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 187, 187, 188,
- 189, 189, 190, 191, 192, 192, 193, 193, 194, 195, 195, 196, 197, 197,
- 198, 199, 199, 200, 201, 201, 202, 203, 203, 204, 204, 205, 206, 206,
- 207, 208, 208, 209, 209, 210, 211, 211, 212, 212, 213, 214, 214, 215,
- 215, 216, 217, 217, 218, 218, 219, 219, 220, 221, 221, 222, 222, 223,
- 224, 224, 225, 225, 226, 226, 227, 227, 228, 229, 229, 230, 230, 231,
- 231, 232, 232, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238,
- 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246,
- 246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253,
- 253, 254, 254, 255
- )
-
- /**
- * <p>
- * A faster replacement for <code>(int)(java.lang.Math.sqrt(x))</code>.
- * Completely accurate for <code>x &lt; 2147483648 (i.e. 2^31)</code>...
- * </p>
- * <p>
- * Adjusted to more closely approximate "(int)(java.lang.Math.sqrt(x) + 0.5)"
- * by Jeff Lawson.
- * </p>
- */
- @throws(classOf[IllegalArgumentException])
- def accurateSqrt(x: Int): Int = {
- if (x >= 0x10000) {
- val xn = if (x >= 0x1000000) {
- var xn0 =
- if (x >= 0x10000000)
- if (x >= 0x40000000) table(x >> 24) << 8
- else table(x >> 22) << 7
- else
- if (x >= 0x4000000) table(x >> 20) << 6
- else table(x >> 18) << 5
-
- xn0 = (xn0 + 1 + (x / xn0)) >> 1
- (xn0 + 1 + (x / xn0)) >> 1
- } else {
- var xn0 =
- if (x >= 0x100000)
- if (x >= 0x400000) table(x >> 16) << 4
- else table(x >> 14) << 3
- else
- if (x >= 0x40000) table(x >> 12) << 2
- else table(x >> 10) << 1
-
- (xn0 + 1 + (x / xn0)) >> 1
- }
- adjustment(x, xn)
- }
- else if (x >= 0x100) {
- val xn =
- if (x >= 0x1000)
- if (x >= 0x4000) (table(x >> 8)) + 1
- else (table(x >> 6) >> 1) + 1
- else
- if (x >= 0x400) (table(x >> 4) >> 2) + 1
- else (table(x >> 2) >> 3) + 1
-
- adjustment(x, xn)
- }
- else if (x >= 0) {
- adjustment(x, table(x) >> 4)
- }
- else {
- throw new IllegalArgumentException("Attempt to take the square root of negative number")
- -1
- }
- }
-
- private def adjustment(x: Int, xn: Int): Int = {
- // Added by Jeff Lawson:
- // need to test:
- // if |xn * xn - x| > |x - (xn-1) * (xn-1)| then xn-1 is more accurate
- // if |xn * xn - x| > |(xn+1) * (xn+1) - x| then xn+1 is more accurate
- // or, for all cases except x == 0:
- // if |xn * xn - x| > x - xn * xn + 2 * xn - 1 then xn-1 is more accurate
- // if |xn * xn - x| > xn * xn + 2 * xn + 1 - x then xn+1 is more accurate
- val xn2 = xn * xn
-
- // |xn * xn - x|
- var comparitor0 = xn2 - x
- if (comparitor0 < 0) comparitor0 = -comparitor0
-
- val twice_xn = xn << 1
-
- // |x - (xn-1) * (xn-1)|
- var comparitor1 = x - xn2 + twice_xn - 1
- if (comparitor1 < 0) comparitor1 = -comparitor1 // only gets here when x == 0
-
- // |(xn+1) * (xn+1) - x|
- val comparitor2 = xn2 + twice_xn + 1 - x
-
- if (comparitor0 > comparitor1)
- if (comparitor1 > comparitor2) xn+1 else xn-1
- else
- if (comparitor0 > comparitor2) xn+1 else xn
- }
-
- def main(args: Array[String]) {
- def toInt(s: String): Option[Int] =
- try { Some(s.toInt) } catch { case e: NumberFormatException => None }
- for (arg <- args; val x = toInt(arg); if !x.isEmpty) {
- val n = x.get
- println("sqrt("+n+") = "+accurateSqrt(n))
- }
- }
-}
diff --git a/src/cldc-library/scala/runtime/StringAdd.scala b/src/cldc-library/scala/runtime/StringAdd.scala
deleted file mode 100644
index 791048b5f2..0000000000
--- a/src/cldc-library/scala/runtime/StringAdd.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/* *\
-** ________ ___ __ ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ |_| **
-** **
-\* */
-
-// $Id$
-
-
-package scala.runtime
-
-
-import Predef._
-
-final class StringAdd(self: Any) {
-
- def +(other: String) = self.toString + other
-
-}
-