// Textbook fragment 08.06 import java.util.Comparator; /** Implementation of a priority queue by means of a sorted node list. */ public class SortedListPriorityQueue implements PriorityQueue { protected PositionList> entries; protected Comparator c; protected Position> actionPos; // variable used by subclasses /** Inner class for entries */ protected static class MyEntry implements Entry { protected K k; // key protected V v; // value public MyEntry(K key, V value) { k = key; v = value; } // methods of the Entry interface public K getKey() { return k; } public V getValue() { return v; } } /** Creates the priority queue with the default comparator. */ public SortedListPriorityQueue () { entries = new NodePositionList>(); c = new DefaultComparator(); } /** Creates the priority queue with the given comparator. */ public SortedListPriorityQueue (Comparator comp) { entries = new NodePositionList>(); c = comp; }