|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractPriorityQueue
m865.datastructures.PriorityQueueAL
This class implements a Queue using a dynamic array
Nested Class Summary | |
class |
PriorityQueueAL.PriorityQueueALIterator
The iterator for this PriorityQueueAL class. |
Field Summary | |
protected java.util.ArrayList |
v
The dynamic array is implemented with the java.util.ArrayList |
Fields inherited from class m865.datastructures.AbstractPriorityQueue |
hash |
Constructor Summary | |
|
PriorityQueueAL()
Constructs a queue whose dynamic array has the default initial size for a ArrayList. |
|
PriorityQueueAL(java.util.Collection c)
Constructs a priority queue which is initialized with the objects in the specified collection. |
|
PriorityQueueAL(int capacity)
Constructs a priority queue whose dynamic array has a specified initial size. |
protected |
PriorityQueueAL(int hash,
java.util.ArrayList v)
Constructs a queue with a specified hash code and a clone of the specified ArrayList. |
Method Summary | |
void |
adjustPriority(Prioritizeable obj,
java.lang.Comparable priority)
Locates the specified object in the heap, changes its priority to the specified priority, and adjusts the location of the object in the heap. |
protected void |
bubbleUp(int child)
Moves this item at the specified position up the heap according to its priority. |
void |
clear()
Removes all the objects from this queue. |
java.lang.Object |
clone()
The Cloneable Interface indicates that the clone method, which is inherited from Object, is implemented so that a true clone (a true and independent copy) of the object is returned. |
boolean |
contains(java.lang.Object obj)
Determines whether the specified object is contained in the priority queue. |
java.lang.Object |
dequeue()
Removes and returns the object at the beginning of the queue. |
protected java.lang.String |
dumpVector()
This method dumps the array containing the priority queue. |
void |
enqueue(Prioritizeable pqi)
Appends an object to the end of the queue. |
boolean |
equals(java.lang.Object obj)
The test for equality. |
java.util.Iterator |
iterator()
A factory method which returns an Iterator to the collection in this priority queue. |
static void |
main(java.lang.String[] args)
This main method tests the PriorityQueueAL class to insure that the elementary functions are correct. |
java.lang.Object |
peek()
Returns the object at the beginning of the queue. |
boolean |
remove(java.lang.Object obj)
Removes the specified object from this priority queue. |
protected void |
siftDown(int parent)
Moves this item at the specified position down the heap according to its priority. |
int |
size()
Determines the size of this queue. |
java.lang.String |
toString()
List the objects in the priority queue in their priorty order. |
Methods inherited from class m865.datastructures.AbstractPriorityQueue |
add, addAll, containsAll, downdateHashCode, hashCode, isEmpty, removeAll, retainAll, toArray, toArray, updateHashCode |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.ArrayList v
Constructor Detail |
public PriorityQueueAL(int capacity)
capacity
- the initial size of the dynamic array.public PriorityQueueAL()
public PriorityQueueAL(java.util.Collection c)
c
- the collection of objects to be initially added to this
priority queue.protected PriorityQueueAL(int hash, java.util.ArrayList v)
hash
- the hash codev
- the ArrayList to be cloned.Method Detail |
protected void bubbleUp(int child)
child
- the index of the specified itempublic void enqueue(Prioritizeable pqi)
enqueue
in class AbstractPriorityQueue
pqi
- the object to be appended to the end of the queue.protected void siftDown(int parent)
parent
- the index of the specified itempublic java.lang.Object dequeue()
dequeue
in class AbstractPriorityQueue
public java.lang.Object peek()
peek
in class AbstractPriorityQueue
public void adjustPriority(Prioritizeable obj, java.lang.Comparable priority)
adjustPriority
in class AbstractPriorityQueue
obj
- the specified prioritizeable objectpriority
- the specified new prioritypublic void clear()
public java.lang.Object clone()
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection
contains
in class AbstractPriorityQueue
obj
- the specified object to be located in the heap.
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection
equals
in class AbstractPriorityQueue
obj
- the object which may be equal to this queue.
public java.util.Iterator iterator()
public boolean remove(java.lang.Object obj)
obj
- the specified object to be removed
public int size()
public java.lang.String toString()
toString
in class AbstractPriorityQueue
protected java.lang.String dumpVector()
public static void main(java.lang.String[] args)
args
- optional command line argument that will be ignored.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |