net.datastructures - version 5.0

net.datastructures
Class SortedListAdaptablePriorityQueue<K,V>

java.lang.Object
  extended by net.datastructures.SortedListPriorityQueue<K,V>
      extended by net.datastructures.SortedListAdaptablePriorityQueue<K,V>
All Implemented Interfaces:
AdaptablePriorityQueue<K,V>, PriorityQueue<K,V>

public class SortedListAdaptablePriorityQueue<K,V>
extends SortedListPriorityQueue<K,V>
implements AdaptablePriorityQueue<K,V>

Implementation of an adaptable priority queue by means of a sorted list.


Nested Class Summary
protected static class SortedListAdaptablePriorityQueue.LocationAwareEntry<K,V>
          Inner class for a location-aware entry
 
Nested classes/interfaces inherited from class net.datastructures.SortedListPriorityQueue
SortedListPriorityQueue.MyEntry<K,V>
 
Field Summary
 
Fields inherited from class net.datastructures.SortedListPriorityQueue
actionPos, c, entries
 
Constructor Summary
SortedListAdaptablePriorityQueue()
          Creates the priority queue with the default comparator
SortedListAdaptablePriorityQueue(Comparator<K> comp)
          Creates the priority queue with the given comparator
SortedListAdaptablePriorityQueue(PositionList<Entry<K,V>> list, Comparator<K> comp)
          Creates the priority queue with the given comparator and list.
 
Method Summary
protected  void checkEntry(Entry ent)
          Determines whether a given entry is valid
 Entry<K,V> insert(K k, V v)
          Inserts a key-value pair and returns the entry created
 Entry<K,V> remove(Entry<K,V> entry)
          Removes and returns the given entry
 K replaceKey(Entry<K,V> entry, K k)
          Replaces the key of the given entry
 V replaceValue(Entry<K,V> e, V value)
          Replaces the value of the given entry
 
Methods inherited from class net.datastructures.SortedListPriorityQueue
checkKey, insertEntry, isEmpty, min, removeMin, setComparator, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.datastructures.PriorityQueue
isEmpty, min, removeMin, size
 

Constructor Detail

SortedListAdaptablePriorityQueue

public SortedListAdaptablePriorityQueue()
Creates the priority queue with the default comparator


SortedListAdaptablePriorityQueue

public SortedListAdaptablePriorityQueue(Comparator<K> comp)
Creates the priority queue with the given comparator


SortedListAdaptablePriorityQueue

public SortedListAdaptablePriorityQueue(PositionList<Entry<K,V>> list,
                                        Comparator<K> comp)
Creates the priority queue with the given comparator and list. The list is assumed to be sorted in nondecreasing order

Method Detail

insert

public Entry<K,V> insert(K k,
                         V v)
                  throws InvalidKeyException
Inserts a key-value pair and returns the entry created

Specified by:
insert in interface PriorityQueue<K,V>
Overrides:
insert in class SortedListPriorityQueue<K,V>
Throws:
InvalidKeyException

remove

public Entry<K,V> remove(Entry<K,V> entry)
Removes and returns the given entry

Specified by:
remove in interface AdaptablePriorityQueue<K,V>

replaceKey

public K replaceKey(Entry<K,V> entry,
                    K k)
Replaces the key of the given entry

Specified by:
replaceKey in interface AdaptablePriorityQueue<K,V>

replaceValue

public V replaceValue(Entry<K,V> e,
                      V value)
Replaces the value of the given entry

Specified by:
replaceValue in interface AdaptablePriorityQueue<K,V>

checkEntry

protected void checkEntry(Entry ent)
                   throws InvalidEntryException
Determines whether a given entry is valid

Throws:
InvalidEntryException

net.datastructures - version 5.0