diff options
Diffstat (limited to 'src/library/scala/collection/parallel/immutable/ParHashSet.scala')
-rw-r--r-- | src/library/scala/collection/parallel/immutable/ParHashSet.scala | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala index 0ef2681567..c9554ae1eb 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala @@ -11,6 +11,7 @@ import scala.collection.parallel.ParSetLike import scala.collection.parallel.Combiner import scala.collection.parallel.ParIterableIterator import scala.collection.parallel.EnvironmentPassingCombiner +import scala.collection.parallel.Unrolled import scala.collection.generic.ParSetFactory import scala.collection.generic.CanCombineFrom import scala.collection.generic.GenericParTemplate @@ -101,21 +102,13 @@ object ParHashSet extends ParSetFactory[ParHashSet] { } -private[immutable] trait HashSetCombiner[T] -extends Combiner[T, ParHashSet[T]] { +private[immutable] abstract class HashSetCombiner[T] +extends collection.parallel.BucketCombiner[T, ParHashSet[T], Any, HashSetCombiner[T]](HashSetCombiner.rootsize) { self: EnvironmentPassingCombiner[T, ParHashSet[T]] => import HashSetCombiner._ - var heads = new Array[Unrolled[Any]](rootsize) - var lasts = new Array[Unrolled[Any]](rootsize) - var size: Int = 0 - - def clear = { - heads = new Array[Unrolled[Any]](rootsize) - lasts = new Array[Unrolled[Any]](rootsize) - } def +=(elem: T) = { - size += 1 + sz += 1 val hc = elem.## val pos = hc & 0x1f if (lasts(pos) eq null) { @@ -128,25 +121,6 @@ self: EnvironmentPassingCombiner[T, ParHashSet[T]] => this } - def combine[N <: T, NewTo >: ParHashSet[T]](other: Combiner[N, NewTo]): Combiner[N, NewTo] = if (this ne other) { - if (other.isInstanceOf[HashSetCombiner[_]]) { - val that = other.asInstanceOf[HashSetCombiner[T]] - var i = 0 - while (i < rootsize) { - if (lasts(i) eq null) { - heads(i) = that.heads(i) - lasts(i) = that.lasts(i) - } else { - lasts(i).next = that.heads(i) - if (that.lasts(i) ne null) lasts(i) = that.lasts(i) - } - i += 1 - } - size = size + that.size - this - } else error("Unexpected combiner type.") - } else this - def result = { val buckets = heads.filter(_ != null) val root = new Array[HashSet[T]](buckets.length) @@ -171,7 +145,8 @@ self: EnvironmentPassingCombiner[T, ParHashSet[T]] => /* tasks */ - class CreateTrie(buckets: Array[Unrolled[Any]], root: Array[HashSet[T]], offset: Int, howmany: Int) extends super.Task[Unit, CreateTrie] { + class CreateTrie(buckets: Array[Unrolled[Any]], root: Array[HashSet[T]], offset: Int, howmany: Int) + extends super.Task[Unit, CreateTrie] { var result = () def leaf(prev: Option[Unit]) = { var i = offset @@ -274,6 +249,3 @@ object HashSetCombiner { - - - |