harpoon.Util
Interface MaxPriorityQueue

All Superinterfaces:
Collection, Iterable
All Known Implementing Classes:
BinHeapPriorityQueue

public interface MaxPriorityQueue
extends Collection

MaxPriorityQueue maintains a Collection of Objects, each with an associated priority. Implementations should make the peekMax and removeMax operations efficient. Implementations need not implement the Object-addition operations of the Collection interface, since they do not associate each added Object with a priority.

Version:
$Id: MaxPriorityQueue.java,v 1.3 2002/04/23 22:29:05 ovy Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>

Method Summary
 void changePriority(Object item, int delta)
          Change the priority of this element by the specified delta.
 Object deleteMax()
          Returns and removes the Object in this with the highest priority.
 int getPriority(Object item)
          Returns the priority currently associated with this item.
 boolean insert(Object item, int priority)
          Inserts item into this, assigning it priority priority.
 Object peekMax()
          Returns the Object in this with the highest priority.
 int setPriority(Object item, int newPriority)
          Changes the priority of this Object to the new, specified value, and returns the old value
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

insert

boolean insert(Object item,
               int priority)
Inserts item into this, assigning it priority priority.

Parameters:
item - Object being inserted
priority - Priority of item

peekMax

Object peekMax()
Returns the Object in this with the highest priority.


deleteMax

Object deleteMax()
Returns and removes the Object in this with the highest priority.


getPriority

int getPriority(Object item)
Returns the priority currently associated with this item.


setPriority

int setPriority(Object item,
                int newPriority)
Changes the priority of this Object to the new, specified value, and returns the old value


changePriority

void changePriority(Object item,
                    int delta)
Change the priority of this element by the specified delta. This is equivalent to setPriority(item, getPriority(item)+delta). It might save time in some implementations.