All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.PriorityVector

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

public class PriorityVector
extends Object
implements PriorityQueue
A vector-based implementation of a priority queue. Similar to an ordered vector, except that only the smallest value may be accessed in this structure.

See Also:
OrderedVector

Constructor Index

 o PriorityVector()
Construct an empty priority queue.

Method Index

 o add(Comparable)
Add a comparable value to the priority queue.
 o clear()
Remove all the values from the priority queue.
 o isEmpty()
Determine if the priority queue is empty.
 o peek()
Fetch the smallest value of the priority queue.
 o remove()
Remove the smallest value of the structure.
 o size()
Determine the size of the priority queue.
 o toString()
Construct a string representation of the priority vector.

Constructors

 o PriorityVector
public PriorityVector()
Construct an empty priority queue.

Postcondition:
constructs a new priority queue

Methods

 o peek
public Comparable peek()
Fetch the smallest value of the priority queue.

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

Returns:
The smallest value of the structure.
 o remove
public Comparable remove()
Remove the smallest value of the structure.

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

Returns:
The smallest value of the structure.
 o add
public void add(Comparable value)
Add a comparable value to the priority queue.

Precondition:
value is non-null
Postcondition:
inserts value in priority queue leaves elements in order

Parameters:
value - The comparable value to be added.
 o isEmpty
public boolean isEmpty()
Determine if the priority queue is empty.

Postcondition:
returns true iff the priority queue is empty

Returns:
True iff there are no elements in the priority queue.
 o size
public int size()
Determine the size of the priority queue.

Postcondition:
returns number of elements in priority queue

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

Postcondition:
removes all elements from priority queue.

 o toString
public String toString()
Construct a string representation of the priority vector.

Postcondition:
returns string representation of priority vector

Returns:
String describing priority vector.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index