diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-10-05 16:22:21 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-10-05 16:22:21 +0000 |
commit | 23c6d4f98541820ffd4085aa3a57dffc88de4786 (patch) | |
tree | b3c28909dc8c9e976f049f4c045b6e8e832bc0e3 /test/files | |
parent | 7553e6901d52ace00bfcb670336c480766c8301c (diff) | |
download | scala-23c6d4f98541820ffd4085aa3a57dffc88de4786.tar.gz scala-23c6d4f98541820ffd4085aa3a57dffc88de4786.tar.bz2 scala-23c6d4f98541820ffd4085aa3a57dffc88de4786.zip |
Adding immutable parallel hashsets.
Fixing an issue with hashset splitters where the splitting does not work
if some elements have already been iterated. Added parallel collections
exception handling. Added parallel collections break control. Renaming
ParHashTrie -> ParHashMap.
The part with immutable.{HashSet, HashMap} - review by rompf
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/scalacheck/HashTrieSplit.scala | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/files/scalacheck/HashTrieSplit.scala b/test/files/scalacheck/HashTrieSplit.scala new file mode 100644 index 0000000000..6b20efe12b --- /dev/null +++ b/test/files/scalacheck/HashTrieSplit.scala @@ -0,0 +1,47 @@ + + + + + +import collection._ + + + + +// checks whether hash tries split their iterators correctly +// even after some elements have been traversed +object Test { + def main(args: Array[String]) { + doesSplitOk + } + + def doesSplitOk = { + val sz = 2000 + var ht = new parallel.immutable.ParHashMap[Int, Int] + // println("creating trie") + for (i <- 0 until sz) ht += ((i + sz, i)) + // println("created trie") + for (n <- 0 until (sz - 1)) { + // println("---------> n = " + n) + val pit = ht.parallelIterator + val pit2 = ht.parallelIterator + var i = 0 + while (i < n) { + pit.next + pit2.next + i += 1 + } + // println("splitting") + val pits = pit.split + val fst = pits(0).toSet + val snd = pits(1).toSet + val orig = pit2.toSet + if (orig.size != (fst.size + snd.size) || orig != (fst ++ snd)) { + println("Original: " + orig) + println("First: " + fst) + println("Second: " + snd) + assert(false) + } + } + } +} |