|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object structure.SkewHeap
public class SkewHeap
An implementation of a priority queue using skew heaps. Skew heaps allow one to construct heaps dynamically without explictly balancing the heaps. Main operation is a merge.
Field Summary | |
---|---|
protected int |
count
The number of nodes within heap. |
protected BinaryTree |
root
The root of the skew heap. |
Constructor Summary | |
---|---|
SkewHeap()
Constructs an empty priority queue. |
Method Summary | |
---|---|
void |
add(java.lang.Comparable value)
Add a value to the priority queue. |
void |
clear()
Remove all the elements from the queue. |
java.lang.Comparable |
getFirst()
Fetch lowest valued (highest priority) item from queue. |
boolean |
isEmpty()
Determine if the queue is empty. |
protected static BinaryTree |
merge(BinaryTree left,
BinaryTree right)
|
java.lang.Comparable |
remove()
Returns the minimum value from the queue. |
int |
size()
Determine the size of the queue. |
java.lang.String |
toString()
Construct a string representation of the heap. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected BinaryTree root
protected int count
Constructor Detail |
---|
public SkewHeap()
Method Detail |
---|
public java.lang.Comparable getFirst()
getFirst
in interface PriorityQueue
public java.lang.Comparable remove()
remove
in interface PriorityQueue
public void add(java.lang.Comparable value)
add
in interface PriorityQueue
value
- The value to be added.public int size()
size
in interface PriorityQueue
public void clear()
clear
in interface PriorityQueue
public boolean isEmpty()
isEmpty
in interface PriorityQueue
protected static BinaryTree merge(BinaryTree left, BinaryTree right)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |