summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorSean McDirmid <sean.mcdirmid@gmail.com>2007-10-02 19:51:33 +0000
committerSean McDirmid <sean.mcdirmid@gmail.com>2007-10-02 19:51:33 +0000
commit96906f755f88930d9e831364c13c27903303eb36 (patch)
treea65344a6bbb22b041724b8ef1950b3878a506d89 /src/library
parent56fa78c91ded4b1d6991672071052c712da53f5d (diff)
downloadscala-96906f755f88930d9e831364c13c27903303eb36.tar.gz
scala-96906f755f88930d9e831364c13c27903303eb36.tar.bz2
scala-96906f755f88930d9e831364c13c27903303eb36.zip
Settings.scala - added mode to eliminate : betw...
Settings.scala - added mode to eliminate : between name and choice Array.scala/BoxedObjectArray - boxing fixes Set.scala - deprecated **, added * to collection.Set.scala Predef.scala - added an implicit coercion from RandomAccessSeq[Char] (including RichString) to String
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/Array.scala2
-rw-r--r--src/library/scala/Predef.scala2
-rw-r--r--src/library/scala/collection/Set.scala12
-rw-r--r--src/library/scala/collection/immutable/Set.scala2
-rw-r--r--src/library/scala/collection/mutable/Set.scala2
-rw-r--r--src/library/scala/runtime/BoxedObjectArray.scala2
6 files changed, 15 insertions, 7 deletions
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index fa282fb044..47fa03f6ff 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -182,7 +182,7 @@ object Array {
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)
+ 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)
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 5faea93821..773eb98157 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -313,6 +313,8 @@ object Predef {
/** 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 : RandomAccessSeq[Char]) : String = x.mkString
def currentThread = java.lang.Thread.currentThread()
diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala
index bf147bcb97..4f412712d6 100644
--- a/src/library/scala/collection/Set.scala
+++ b/src/library/scala/collection/Set.scala
@@ -72,8 +72,14 @@ trait Set[A] extends (A => Boolean) with Collection[A] {
*/
def subsetOf(that: Set[A]): Boolean = forall(that.contains)
- /** set intersection */
- def *(that : Set[A]) : Set[A] = {
+ @deprecated def *(that : Set[A]) : Set[A] = this ** that
+
+ /** Intersect. It computes an intersection with set <code>that</code>.
+ * It removes all the elements that are not present in <code>that</code>.
+ *
+ * @param that the set to intersect with
+ */
+ def **(that : Set[A]) : Set[A] = {
val min = Math.min(size, that.size)
val buf = new Array[A](min)
var count = 0
@@ -91,7 +97,7 @@ trait Set[A] extends (A => Boolean) with Collection[A] {
import scala.collection.mutable.HashSet
val ret = new HashSet[A]
ret ++= buf.projection.take(count)
- ret.readOnly
+ ret
}
}
/** Compares this set with another object and returns true, iff the
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index a759ea4bcf..903dc6240c 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -151,7 +151,7 @@ trait Set[A] extends AnyRef with collection.Set[A] {
*
* @param that the set to intersect with
*/
- def ** (that: collection.Set[A]): Set[A] = intersect(that)
+ override def ** (that: collection.Set[A]): Set[A] = intersect(that)
/** Returns the set resulting from applying the given function <code>f</code> to each
* element of this set.
diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala
index d3445a56d6..4b4c4d39f9 100644
--- a/src/library/scala/collection/mutable/Set.scala
+++ b/src/library/scala/collection/mutable/Set.scala
@@ -209,7 +209,7 @@ trait Set[A] extends collection.Set[A] with Scriptable[Message[A]] with Cloneabl
/** Return a read-only projection of this set */
def readOnly : scala.collection.Set[A] = new scala.collection.Set[A] {
def contains(item : A) = Set.this.contains(item)
- override def toString = "read-only-" + Set.this.toString
+ override def toString = "ro-" + Set.this.toString
override def size = Set.this.size
override def elements = Set.this.elements
}
diff --git a/src/library/scala/runtime/BoxedObjectArray.scala b/src/library/scala/runtime/BoxedObjectArray.scala
index 4826518173..4eaec78c55 100644
--- a/src/library/scala/runtime/BoxedObjectArray.scala
+++ b/src/library/scala/runtime/BoxedObjectArray.scala
@@ -63,7 +63,7 @@ final class BoxedObjectArray(val value: Array[AnyRef]) extends BoxedArray {
new BoxedObjectArray(result)
}
override protected def newArray(length : Int, elements : Iterator[Any]) = {
- val result = new Array[AnyRef](length)
+ val result = create(length)
elements.map(_.asInstanceOf[AnyRef]).copyToArray(result, 0)
new BoxedObjectArray(result)
}