All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class structure.SkewHeap

java.lang.Object
   |
   +----structure.SkewHeap

public class SkewHeap
extends Object
implements PriorityQueue
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.


Constructor Index

 o SkewHeap()
Constructs an empty priority queue.

Method Index

 o add(Comparable)
Add a value to the priority queue.
 o clear()
Remove all the elements from the queue.
 o isEmpty()
Determine if the queue is empty.
 o peek()
Fetch lowest valued (highest priority) item from queue.
 o remove()
Returns the minimum value from the queue.
 o size()
Determine the size of the queue.
 o toString()
Construct a string representation of the heap.

Constructors

 o SkewHeap
 public SkewHeap()
Constructs an empty priority queue.

Postcondition:
creates an empty priority queue

Methods

 o peek
 public Comparable peek()
Fetch lowest valued (highest priority) item from queue.

Precondition:
!isEmpty()
Postcondition:
returns the minimum value in priority queue

Returns:
The smallest value from queue.
 o remove
 public Comparable remove()
Returns the minimum value from the queue.

Precondition:
!isEmpty()
Postcondition:
returns and removes minimum value from queue

Returns:
The minimum value in the queue.
 o add
 public void add(Comparable value)
Add a value to the priority queue.

Precondition:
value is non-null comparable
Postcondition:
value is added to priority queue

Parameters:
value - The value to be added.
 o size
 public int size()
Determine the size of the queue.

Postcondition:
returns number of elements within queue

Returns:
The number of elements within the queue.
 o clear
 public void clear()
Remove all the elements from the queue.

Postcondition:
removes all elements from queue

 o isEmpty
 public boolean isEmpty()
Determine if the queue is empty.

Postcondition:
returns true iff no elements are in queue

Returns:
True if the queue is empty.
 o toString
 public String toString()
Construct a string representation of the heap.

Postcondition:
returns string representation of heap

Returns:
The string representing the heap.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index