|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ProGAL.dataStructures.Heap
public class Heap
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)
|
|
Heap(int capacity,
SortTool tool)
|
|
Heap(Set<java.lang.Object> set,
SortTool tool)
|
Method Summary | |
---|---|
void |
clear()
remove all elements |
java.lang.Object |
extract()
Return and remove least element, or null if empty |
java.lang.Object |
getItem(int i)
returns the i-th object in the binary heap. |
java.lang.Object[] |
getObjects()
|
int |
getSize()
|
void |
insert(java.lang.Object x)
|
boolean |
isEmpty()
returns true if the heap is empty. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
peek()
Return least element without removing it, or null if empty |
void |
setItem(int i,
java.lang.Object x)
|
void |
siftDown(int k)
|
void |
siftUp(int k)
|
int |
size()
Return number of elements |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Heap(int capacity, SortTool tool) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public Heap(int capacity)
public Heap(Set<java.lang.Object> set, SortTool tool)
Method Detail |
---|
public java.lang.Object[] getObjects()
public boolean isEmpty()
public int getSize()
public java.lang.Object getItem(int i)
i
-
public void setItem(int i, java.lang.Object x)
public void siftUp(int k)
public void siftDown(int k)
public void insert(java.lang.Object x)
public java.lang.Object extract()
public java.lang.Object peek()
public int size()
public void clear()
public static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |