예제 #1
0
  void testAccuracy(AbstractPriorityQueue<Integer> q) {
    List<Integer> keys = DSUtils.toIntegerList(4, 1, 3, 2, 5, 6, 8, 3, 4, 7, 5, 9, 7);

    for (Integer key : keys) q.add(key);

    Collections.sort(keys, Collections.reverseOrder());

    for (Integer key : keys) assertEquals(q.removeMax(), key);
  }
예제 #2
0
  void addRuntime(AbstractPriorityQueue<Integer> queue, long[] times, int[] keys) {
    long st, et;

    st = System.currentTimeMillis();

    for (int key : keys) queue.add(key);

    et = System.currentTimeMillis();
    times[0] += et - st;

    st = System.currentTimeMillis();

    while (!queue.isEmpty()) queue.removeMax();

    et = System.currentTimeMillis();
    times[1] += et - st;
  }