diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-27 20:48:31 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-27 20:48:31 +0000 |
commit | c7cd961ad1beef39412544863fb58d3a7277eb28 (patch) | |
tree | 2eee2cfa9a0193808d5c3fb6dbdf761a0166ee74 /test | |
parent | cc5e79c9ec9cea8d0f22020b528877d8f6e00153 (diff) | |
download | scala-c7cd961ad1beef39412544863fb58d3a7277eb28.tar.gz scala-c7cd961ad1beef39412544863fb58d3a7277eb28.tar.bz2 scala-c7cd961ad1beef39412544863fb58d3a7277eb28.zip |
Reintegrated PriorityQueue.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/priorityQueue.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/run/priorityQueue.scala b/test/files/run/priorityQueue.scala new file mode 100644 index 0000000000..9f453788fc --- /dev/null +++ b/test/files/run/priorityQueue.scala @@ -0,0 +1,24 @@ + +// populate a priority queue a few different ways and make sure they all seem equal +object Test extends Application { + import scala.collection.mutable.PriorityQueue + import scala.util.Random.nextInt + val pq1 = new PriorityQueue[String] + val pq2 = new PriorityQueue[String] + val pq3 = new PriorityQueue[String] + val pq4 = new PriorityQueue[String] + + val strings = (1 to 20).toList map (i => List.fill((Math.abs(nextInt % 20)) + 1)("x").mkString) + + pq1 ++= strings + pq2 ++= strings.reverse + for (s <- strings) pq3 += s + for (s <- strings.reverse) pq4 += s + + val pqs = List(pq1, pq2, pq3, pq4, pq1.clone, pq2.clone) + + for (queue1 <- pqs ; queue2 <- pqs) { + assert(queue1 == queue2) + assert(queue1.max == queue2.max) + } +} |