Colt 1.0.2

edu.oswego.cs.dl.util.concurrent
Class Heap

java.lang.Object
  |
  +--edu.oswego.cs.dl.util.concurrent.Heap

public class Heap
extends Object

A heap-based priority queue, without any concurrency control (i.e., no blocking on empty/full states). This class provides the data structure mechanics for BoundedPriorityQueue.

The class currently uses a standard array-based heap, as described in, for example, Sedgewick's Algorithms text. All methods are fully synchronized. In the future, it may instead use structures permitting finer-grained locking.

[ Introduction to this package. ]


Constructor Summary
Heap(int capacity)
          Create a Heap with the given capacity, and relying on natural ordering.
Heap(int capacity, Comparator cmp)
          Create a Heap with the given initial capacity and comparator
 
Method Summary
 void clear()
          remove all elements
 Object extract()
          Return and remove least element, or null if empty
 void insert(Object x)
          insert an element, resize if necessary
 Object peek()
          Return least element without removing it, or null if empty
 int size()
          Return number of elements
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Heap

public Heap(int capacity)
Create a Heap with the given capacity, and relying on natural ordering.

Heap

public Heap(int capacity,
            Comparator cmp)
     throws IllegalArgumentException
Create a Heap with the given initial capacity and comparator
Throws:
IllegalArgumentException - if capacity less or equal to zero
Method Detail

clear

public void clear()
remove all elements

extract

public Object extract()
Return and remove least element, or null if empty

insert

public void insert(Object x)
insert an element, resize if necessary

peek

public Object peek()
Return least element without removing it, or null if empty

size

public int size()
Return number of elements

Colt 1.0.2

Submit a bug or feature. Check the Colt home page for the latest news.