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
PriorityVector()
- Construct an empty priority queue.
add(Comparable)
- Add a comparable value to the priority queue.
clear()
- Remove all the values from the priority queue.
isEmpty()
- Determine if the priority queue is empty.
peek()
- Fetch the smallest value of the priority queue.
remove()
- Remove the smallest value of the structure.
size()
- Determine the size of the priority queue.
toString()
- Construct a string representation of the priority vector.
PriorityVector
public PriorityVector()
- Construct an empty priority queue.
- Postcondition:
- constructs a new priority queue
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.
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.
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.
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.
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.
clear
public void clear()
- Remove all the values from the priority queue.
- Postcondition:
- removes all elements from priority queue.
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