summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-05-24 15:26:58 +0000
committermichelou <michelou@epfl.ch>2007-05-24 15:26:58 +0000
commitcd0434d53062a6f10a77a4b98bf01e36fce2d077 (patch)
treedad6770d9f1f5ed9531ec533276ff1dba89c9696
parente9dcc566395b7566b815720e48543438d697c233 (diff)
downloadscala-cd0434d53062a6f10a77a4b98bf01e36fce2d077.tar.gz
scala-cd0434d53062a6f10a77a4b98bf01e36fce2d077.tar.bz2
scala-cd0434d53062a6f10a77a4b98bf01e36fce2d077.zip
import Predef
-rw-r--r--src/library/scala/collection/mutable/ResizableArray.scala31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/library/scala/collection/mutable/ResizableArray.scala b/src/library/scala/collection/mutable/ResizableArray.scala
index c6bd2ebeb0..11560d07ee 100644
--- a/src/library/scala/collection/mutable/ResizableArray.scala
+++ b/src/library/scala/collection/mutable/ResizableArray.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -11,6 +11,8 @@
package scala.collection.mutable
+import Predef._
+
/** This class is used internally to implement data structures that
* are based on resizable arrays.
* //todo enrich with more efficient operations
@@ -22,11 +24,9 @@ trait ResizableArray[A] extends RandomAccessSeq[A] {
protected val initialSize: Int = 16
protected var array: Array[A] = new Array[A](initialSize)
- private var size1 : Int = 0
- protected def size0 : Int = size1
- protected def size0_=(sz : Int) = {
- size1 = sz
- }
+ private var size1: Int = 0
+ protected def size0: Int = size1
+ protected def size0_=(sz: Int) { size1 = sz }
//##########################################################################
// implement/override methods of Seq[A]
@@ -39,7 +39,7 @@ trait ResizableArray[A] extends RandomAccessSeq[A] {
/** remove elements of this array at indices after <code>sz</code>
*/
- def reduceToSize(sz : Int) = {
+ def reduceToSize(sz: Int) {
if (sz > size0) throw new IllegalArgumentException
size0 = sz
}
@@ -50,14 +50,16 @@ trait ResizableArray[A] extends RandomAccessSeq[A] {
* @param xs the array to fill.
* @param start starting index.
*/
- override def copyToArray[B >: A](xs: Array[B], start: Int): Unit =
+ override def copyToArray[B >: A](xs: Array[B], start: Int) {
Array.copy(array, 0, xs, start, size0)
+ }
/** Copy all elements to a buffer
* @param The buffer to which elements are copied
*/
- override def copyToBuffer[B >: A](dest: Buffer[B]): Unit =
+ override def copyToBuffer[B >: A](dest: Buffer[B]) {
dest.++=(array.asInstanceOf[Array[B]], 0, size0)
+ }
/** Returns a new iterator over all elements of this resizable array.
*/
@@ -70,7 +72,7 @@ trait ResizableArray[A] extends RandomAccessSeq[A] {
//##########################################################################
/** ensure that the internal array has at n cells */
- protected def ensureSize(n: Int): Unit =
+ protected def ensureSize(n: Int) {
if (n > array.length) {
var newsize = array.length * 2
while (n > newsize)
@@ -79,10 +81,11 @@ trait ResizableArray[A] extends RandomAccessSeq[A] {
Array.copy(array, 0, newar, 0, size0)
array = newar
}
+ }
/** Swap two elements of this array.
*/
- protected def swap(a: Int, b: Int): Unit = {
+ protected def swap(a: Int, b: Int) {
val h = array(a)
array(a) = array(b)
array(b) = h
@@ -90,7 +93,7 @@ trait ResizableArray[A] extends RandomAccessSeq[A] {
/** Move parts of the array.
*/
- protected def copy(m: Int, n: Int, len: Int) =
+ protected def copy(m: Int, n: Int, len: Int) {
Array.copy(array, m, array, n, len)
-
+ }
}