// ... (continuation of SortedSeqPriorityQueueLoc) void removeMin() // remove minimum throw(EmptyContainerException) { Locator minLoc = min(); // get locator to min remove(minLoc); // remove it } void replaceElement(Locator& loc, const Element& newElement) throw(InvalidPositionException) { // replace an element if (loc.isNull()) throw InvalidPositionException("Replacement using null locator"); loc.locItem->item.setElement(newElement); // modify the element } void replaceKey(Locator& loc, const Key& newKey) // replace a key throw(InvalidPositionException) { if (loc.isNull()) throw InvalidPositionException("Replacement using null locator"); S.remove(loc.locItem->pos); // remove from sequence loc.locItem->item.setKey(newKey); // modify the key locInsert(loc.locItem); // reinsert in sequence } // ... (housekeeping and other functions omitted) }; template <typename Key, typename Element, typename Comp> void SortedSeqPriorityQueueLoc<Key, Element, Comp>:: locInsert(LocItemPtr locItem) { // insert utility Position& pos = locItem->pos; // insertion position Key k = locItem->key(); // key to insert if (S.isEmpty()) pos = S.insertFirst(locItem); // if empty insert first else if (comp(k, key(S.last())) > 0) // greater than last? pos = S.insertAfter(S.last(), locItem); // insert at end else { Position curr = S.first(); // start search while (comp(k, key(curr)) > 0) // skip over small keys curr = S.after(curr); pos = S.insertBefore(curr, locItem); // insert here } }