summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-10-06 09:01:52 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-10-06 09:01:52 +0000
commitbf84cd2f44e3be39247e7fd05a93ca660aed1cc0 (patch)
tree62d0ab326a7f48507b591db08aff2908c00ba0fe /src
parent23c6d4f98541820ffd4085aa3a57dffc88de4786 (diff)
downloadscala-bf84cd2f44e3be39247e7fd05a93ca660aed1cc0.tar.gz
scala-bf84cd2f44e3be39247e7fd05a93ca660aed1cc0.tar.bz2
scala-bf84cd2f44e3be39247e7fd05a93ca660aed1cc0.zip
Temporary fix for #3796. No review
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/RedBlack.scala26
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala67
2 files changed, 15 insertions, 78 deletions
diff --git a/src/library/scala/collection/immutable/RedBlack.scala b/src/library/scala/collection/immutable/RedBlack.scala
index ecd7a65889..c1c5e1dc1a 100644
--- a/src/library/scala/collection/immutable/RedBlack.scala
+++ b/src/library/scala/collection/immutable/RedBlack.scala
@@ -173,17 +173,21 @@ abstract class RedBlack[A] {
if (!middle._1) return middle
return this.right.visit(middle._2)(f)
}
- override def range(from: Option[A], until: Option[A]): Tree[B] = {
- if (from == None && until == None) return this
- if (from != None && isSmaller(key, from.get)) return right.range(from, until);
- if (until != None && (isSmaller(until.get,key) || !isSmaller(key,until.get)))
- return left.range(from, until);
- val newLeft = left.range(from, None)
- val newRight = right.range(None, until)
- if ((newLeft eq left) && (newRight eq right)) this
- else if (newLeft eq Empty) newRight.upd(key, value);
- else if (newRight eq Empty) newLeft.upd(key, value);
- else mkTree(isBlack, key, value, newLeft, newRight)
+ override def range(from: Option[A], until: Option[A]): Tree[B] = {
+ // if (from == None && until == None) return this
+ // if (from != None && isSmaller(key, from.get)) return right.range(from, until);
+ // if (until != None && (isSmaller(until.get,key) || !isSmaller(key,until.get)))
+ // return left.range(from, until);
+ // val newLeft = left.range(from, None)
+ // val newRight = right.range(None, until)
+ // if ((newLeft eq left) && (newRight eq right)) this
+ // else if (newLeft eq Empty) newRight.upd(key, value);
+ // else if (newRight eq Empty) newLeft.upd(key, value);
+ // else mkTree(isBlack, key, value, newLeft, newRight)
+ iterator
+ .dropWhile { case (key, _) => from forall (isSmaller(key, _)) }
+ .takeWhile { case (key, _) => until forall (isSmaller(_, key)) }
+ .foldLeft(Empty: Tree[B]) { case (tree, (key, value)) => tree.update(key, value) }
}
def first = if (left .isEmpty) key else left.first
def last = if (right.isEmpty) key else right.last
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index bdfb92a405..7bbc6c09f4 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -1058,72 +1058,6 @@ self =>
}
}
- @deprecated
- protected[this] class PartialScan[U >: T, A >: U](z: U, op: (U, U) => U, val from: Int, val len: Int, array: Array[A], protected[this] val pit: ParIterableIterator[T])
- extends Accessor[ScanTree[U], PartialScan[U, A]] {
- var result: ScanTree[U] = null
- def leaf(prev: Option[ScanTree[U]]) = {
- result = new ScanTree[U](from, len)
- val firstElem = prev match {
- case Some(st) => if (st.chunkFinished) {
- result.chunkFinished = true
- st.value
- } else z
- case None => z
- }
- pit.scanToArray(firstElem, op, array, from)
- result.value = array(from + len - 1).asInstanceOf[U]
- if (from == 1) result.chunkFinished = true
- }
- protected[this] def newSubtask(p: ParIterableIterator[T]) = unsupported
- override def split = {
- val pits = pit.split
- for ((p, untilp) <- pits zip pits.scanLeft(0)(_ + _.remaining); if untilp < len) yield {
- val plen = p.remaining min (len - untilp)
- new PartialScan[U, A](z, op, from + untilp, plen, array, p)
- }
- }
- override def merge(that: PartialScan[U, A]) = {
- // create scan tree node
- val left = result
- val right = that.result
- val ns = new ScanTree[U](left.from, left.len + right.len)
- ns.left = left
- ns.right = right
- ns.value = op(left.value, right.value)
- ns.pushDownOnRight(left.value, op)
-
- // commented out - didn't result in performance gains
- // check if left tree has finished cumulating
- // if it did, start the cumulate step in the right subtree before returning to the root
- //if (left.chunkFinished) {
- // right.activeScan = execute(new ApplyScanTree[U](Some(left.value), op, right, array))
- //}
-
- // set result
- result = ns
- }
- }
-
- @deprecated
- protected[this] class ApplyScanTree[U >: T, A >: U](first: Option[U], op: (U, U) => U, st: ScanTree[U], array: Array[A])
- extends super.Task[Unit, ApplyScanTree[U, A]] {
- var result = ();
- def leaf(prev: Option[Unit]) = if (st.shouldApply) apply(st, first.get)
- private def apply(st: ScanTree[U], elem: U): Unit = if (st.shouldApply) {
- if (st.isLeaf) st.applyToInterval(elem, op, array)
- else {
- apply(st.left, elem)
- apply(st.right, st.left.value)
- }
- } else if (st.isApplying) st.activeScan()
- def split = collection.mutable.ArrayBuffer(
- new ApplyScanTree(first, op, st.left, array),
- new ApplyScanTree(Some(st.left.value), op, st.right, array)
- )
- def shouldSplitFurther = (st.left ne null) && (st.right ne null)
- }
-
protected[this] class ApplyToArray[U >: T, A >: U](elem: U, op: (U, U) => U, from: Int, len: Int, array: Array[A])
extends super.Task[Unit, ApplyToArray[U, A]] {
var result: Unit = ()
@@ -1198,7 +1132,6 @@ self =>
new ScanWithScanTree(Some(st.left.value), op, st.right, src, dest)
)
def shouldSplitFurther = (st.left ne null) && (st.right ne null)
-
}
protected[this] class FromArray[S, A, That](array: Array[A], from: Int, len: Int, cbf: CanCombineFrom[Repr, S, That])