summaryrefslogtreecommitdiff
path: root/test/disabled/scalacheck/HashTrieSplit.scala
blob: cbf565095c19a1b1166e39b40e9913fcb953f897 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)
      }
    }
  }
}