Example usage for org.apache.commons.collections BinaryHeap remove

List of usage examples for org.apache.commons.collections BinaryHeap remove

Introduction

In this page you can find the example usage for org.apache.commons.collections BinaryHeap remove.

Prototype

public boolean remove(Object o) 

Source Link

Usage

From source file:org.drools.util.BinaryHeapPriorityQueueTest.java

public void xxxtestBasic() {
    final Random random = new Random();
    final List items = new LinkedList();

    final BinaryHeap queue = new BinaryHeap();

    for (int i = 0; i < 100000; ++i) {
        items.add(new LongQueueable(random.nextLong()));
    }/* w w  w . j  ava  2  s.co m*/

    final long startEnqueue = System.currentTimeMillis();

    for (final Iterator i = items.iterator(); i.hasNext();) {
        queue.add(i.next());
    }

    final long elapsedEnqueue = System.currentTimeMillis() - startEnqueue;

    final long startDequeue = System.currentTimeMillis();

    for (final Iterator i = items.iterator(); i.hasNext();) {
        queue.remove(i.next());
    }

    //        while (!queue.isEmpty()) {
    //            queue.pop();
    //        }

    final long elapsedDequeue = System.currentTimeMillis() - startDequeue;

    System.out.println("elapsedEnqueue = " + elapsedEnqueue);
    System.out.println("elapsedDequeue = " + elapsedDequeue);
}