|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.SortedListPriorityQueue
Realization of a priority queue by means of a sorted linked-list in nondecreasing order.
Nested Class Summary | |
protected static class |
SortedListPriorityQueue.DefaultComparator
Inner class for a default comparator using the natural ordering |
protected static class |
SortedListPriorityQueue.MyEntry
Inner class for entries |
Field Summary | |
protected Position |
actionPos
|
protected Comparator |
c
|
protected List |
L
|
Constructor Summary | |
SortedListPriorityQueue()
Creates the priority queue with the default comparator. |
|
SortedListPriorityQueue(Comparator comp)
Creates the priority queue with the given comparator. |
|
SortedListPriorityQueue(List list,
Comparator comp)
Creates the priority queue with the given comparator and list. |
Method Summary | |
protected boolean |
checkKey(Object key)
Determines whether a key is valid. |
Entry |
insert(Object k,
Object v)
Inserts a key-value pair and return the entry created. |
protected void |
insertEntry(Entry e)
Auxiliary method used for insertion. |
boolean |
isEmpty()
Returns whether the priority queue is empty. |
protected Object |
key(Position pos)
Returns the key stored at a given node. |
Entry |
min()
Returns but does not remove an entry with minimum key. |
Entry |
removeMin()
Removes and returns an entry with minimum key. |
void |
setComparator(Comparator comp)
Sets the comparator for this priority queue. |
int |
size()
Returns the number of elements in the priority queue. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected List L
protected Comparator c
protected Position actionPos
Constructor Detail |
public SortedListPriorityQueue()
public SortedListPriorityQueue(Comparator comp)
public SortedListPriorityQueue(List list, Comparator comp)
Method Detail |
public void setComparator(Comparator comp) throws IllegalStateException
IllegalStateException
- if priority queue is not emptypublic int size()
size
in interface PriorityQueue
public boolean isEmpty()
isEmpty
in interface PriorityQueue
public Entry min() throws EmptyPriorityQueueException
min
in interface PriorityQueue
EmptyPriorityQueueException
public Entry insert(Object k, Object v) throws InvalidKeyException
insert
in interface PriorityQueue
InvalidKeyException
protected void insertEntry(Entry e)
public Entry removeMin() throws EmptyPriorityQueueException
removeMin
in interface PriorityQueue
EmptyPriorityQueueException
protected Object key(Position pos)
protected boolean checkKey(Object key) throws InvalidKeyException
InvalidKeyException
public String toString()
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |