drasys.or.cont
Class BinaryHeap

java.lang.Object
  |
  +--drasys.or.cont.BinaryHeap
Direct Known Subclasses:
PriorityQueue

public class BinaryHeap
extends java.lang.Object
implements PriorityQueueI, java.io.Serializable

References:

Introduction to Algorithms
    Thomas H. Cormen, et al / Hardcover / Published 1990

See Also:
BinomialHeap, PriorityQueue, Serialized Form

Constructor Summary
BinaryHeap(CompareI compare)
           
BinaryHeap(CompareI compare, int capacity)
           
 
Method Summary
 void changePriority(PairI pelement, java.lang.Object priority)
          Change the priority of a element in the queue.
 boolean check()
          Check the integrity of the internal data structures.
 PairI elementAt(int i)
           
 java.util.Enumeration elements()
          Get an enumerator to access all the elements in random order.
 void ensureCapacity(int capacity)
          Ensure that the queue can hold this many elements.
 PairI getHead()
          Access the next element in the queue and leave the entry in the queue.
 PairI insert(java.lang.Object priority)
           
 PairI insert(java.lang.Object priority, java.lang.Object object)
          Insert a new element into the queue, with separate priority and value objects.
 PairI popHead()
          Access the next element in the queue and remove the entry from the queue.
 void removeAllElements()
          Remove all elements from the queue.
 void setCompare(CompareI compare)
          Sets a new comparison function.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryHeap

public BinaryHeap(CompareI compare)

BinaryHeap

public BinaryHeap(CompareI compare,
                  int capacity)
Method Detail

elementAt

public PairI elementAt(int i)

size

public int size()
Specified by:
size in interface PriorityQueueI
Returns:
The number of elements in the heap.
See Also:
PriorityQueueI

removeAllElements

public void removeAllElements()
Description copied from interface: PriorityQueueI
Remove all elements from the queue.
Specified by:
removeAllElements in interface PriorityQueueI
See Also:
PriorityQueueI

ensureCapacity

public void ensureCapacity(int capacity)
Ensure that the queue can hold this many elements.
Specified by:
ensureCapacity in interface PriorityQueueI

elements

public java.util.Enumeration elements()
Description copied from interface: PriorityQueueI
Get an enumerator to access all the elements in random order.
Specified by:
elements in interface PriorityQueueI
See Also:
PriorityQueueI

check

public boolean check()
Description copied from interface: PriorityQueueI
Check the integrity of the internal data structures.
Specified by:
check in interface PriorityQueueI
See Also:
PriorityQueueI

changePriority

public void changePriority(PairI pelement,
                           java.lang.Object priority)
                    throws InvalidPriorityException
Description copied from interface: PriorityQueueI
Change the priority of a element in the queue.
Specified by:
changePriority in interface PriorityQueueI
Throws:
InvalidPriorityException - All priorities are valid for this heap..
See Also:
PriorityQueueI

getHead

public PairI getHead()
Description copied from interface: PriorityQueueI
Access the next element in the queue and leave the entry in the queue.
Specified by:
getHead in interface PriorityQueueI
See Also:
PriorityQueueI

popHead

public PairI popHead()
Description copied from interface: PriorityQueueI
Access the next element in the queue and remove the entry from the queue.
Specified by:
popHead in interface PriorityQueueI
See Also:
PriorityQueueI

setCompare

public void setCompare(CompareI compare)
Sets a new comparison function. This will empty the queue if it contains any objects.
Specified by:
setCompare in interface PriorityQueueI

insert

public PairI insert(java.lang.Object priority)
See Also:
PriorityQueueI

insert

public PairI insert(java.lang.Object priority,
                    java.lang.Object object)
Description copied from interface: PriorityQueueI
Insert a new element into the queue, with separate priority and value objects.
Specified by:
insert in interface PriorityQueueI
See Also:
PriorityQueueI


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com