Test.java
Test.java — Plain Text, 636 bytes
File contents
package ex11; import java.util.*; public class Test { public static void main(String[] args) { Random random = new Random(); Heap pq = new Heap(); int rounds = 0; while (random.nextBoolean()) { pq.enqueue(random.nextInt(10)); rounds++; } System.out.println(rounds + " rounds"); Comparable lastElement = Integer.MIN_VALUE; for (int i = 0; i < rounds; i++) { Comparable dq = pq.removeFirst(); if (dq.compareTo(lastElement) < 0) { throw new UnsupportedOperationException(); } lastElement = dq; } } }