PriorityQueue
Keywords: weiss.nonstandard.PriorityQueue interface

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weiss.nonstandard
Interface PriorityQueue<AnyType extends java.lang.Comparable<? super AnyType>>

All Known Implementing Classes:
  BinaryHeap

    public interface PriorityQueue<AnyType extends java.lang.Comparable<? super AnyType>>

PriorityQueue interface. Some priority queues may support a decreaseKey operation, but this is considered an advanced operation. If so, a Position is returned by insert. Note that all "matching" is based on the compareTo method.

Nested Class Summary
`static interface` | `PriorityQueue.Position<AnyType>` The Position interface represents a type that can be used for the decreaseKey operation.

Method Summary
`void` | `decreaseKey(PriorityQueue.Position<AnyType> p, AnyType newVal)` Change the value of the item stored in the pairing heap.
`AnyType` | `deleteMin()` Remove the smallest item from the priority queue.
`AnyType` | `findMin()` Find the smallest item in the priority queue.
`PriorityQueue.Position<AnyType>` | `insert(AnyType x)` Insert into the priority queue, maintaining heap order.
`boolean` | `isEmpty()` Test if the priority queue is logically empty.
`void` | `makeEmpty()` Make the priority queue logically empty.
`int` | `size()` Returns the size.

Method Detail

### insert

    PriorityQueue.Position<AnyType> insert(AnyType x)

  Insert into the priority queue, maintaining heap order. Duplicates are allowed.

  Parameters:
    `x` - the item to insert.
  Returns:
    may return a Position useful for decreaseKey.

### findMin

    AnyType findMin()

  Find the smallest item in the priority queue.

  Returns:
    the smallest item.
  Throws:
    `UnderflowException` - if empty.

### deleteMin

    AnyType deleteMin()

  Remove the smallest item from the priority queue.

  Returns:
    the smallest item.
  Throws:
    `UnderflowException` - if empty.

### isEmpty

    boolean isEmpty()

  Test if the priority queue is logically empty.

  Returns:
    true if empty, false otherwise.

### makeEmpty

    void makeEmpty()

  Make the priority queue logically empty.

### size

    int size()

  Returns the size.

  Returns:
    current size.

### decreaseKey

    void decreaseKey(PriorityQueue.Position<AnyType> p,
                     AnyType newVal)

  Change the value of the item stored in the pairing heap. This is considered an advanced operation and might not be supported by all priority queues. A priority queue will signal its intention to not support decreaseKey by having insert return null consistently.

  Parameters:
    `p` - any non-null Position returned by insert.
    `newVal` - the new value, which must be smaller than the currently stored value.
  Throws:
    `java.lang.IllegalArgumentException` - if p invalid.
    `java.lang.UnsupportedOperationException` - if appropriate.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD