Ejemplo n.º 1
0
 /* Worst-case O(k) */
 public AmortizedPQueue<E> plusAll(Collection<? extends E> list) {
   AmortizedPQueue<E> result = this;
   for (E e : list) {
     result = result.plus(e);
   }
   return result;
 }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    AmortizedPQueue<Integer> queue = new AmortizedPQueue<Integer>();

    queue = queue.plus(1).minus().minus().plus(2).plus(3).plus(4).plus(5).minus().plus(6).plus(7);
    PQueue<Integer> original = queue;

    System.out.println("    \t" + queue.front + " " + queue.back);

    while (queue.size() > 0) {
      int i = queue.peek();
      queue = queue.minus();
      System.out.println(i + " <- \t" + queue.front + " " + queue.back);
    }

    System.out.println(original);
  }