structure
Interface MergeableHeap<ELTTYPE extends java.lang.Comparable<ELTTYPE>>

All Superinterfaces:
PriorityQueue<ELTTYPE>
All Known Implementing Classes:
SkewHeap

public interface MergeableHeap<ELTTYPE extends java.lang.Comparable<ELTTYPE>>
extends PriorityQueue<ELTTYPE>

Interface describing mergeable min heaps. Min heaps are collections of Comparable data that guarantee efficient access to the smallest element in the structure. Mergeable Min heaps, also provide an efficient technique for merging two mergeable heaps of the same type. Mergeable heaps are quite similar to PriorityQueue.

Example Usage:

 public static void main(String[] argv){
        //initialize a new fib heap
        MergeableHeap programmers = new FibHeap();

        //add programmers and their ages to heap
        //ages current of 7/22/2002
        programmers.add(new ComparableAssociation(new Integer(22), "Evan"));
        programmers.add(new ComparableAssociation(new Integer(19), "Chris"));
        programmers.add(new ComparableAssociation(new Integer(20), "Shimon"));
        programmers.add(new ComparableAssociation(new Integer(21), "Diane"));
        programmers.add(new ComparableAssociation(new Integer(21), "Lida"));    
        programmers.add(new ComparableAssociation(new Integer(20), "Rob"));     
        programmers.add(new ComparableAssociation(new Integer(20), "Sean"));    

        //print out programmers 
        while(!programmers.PriorityQueue.isEmpty()){
            ComparableAssociation p = (ComparableAssociation)programmers.PriorityQueue.remove();
            System.out.println(p.getValue() + " is " + p.getKey() + " years old.");
        }
 }
 


Method Summary
 void merge(MergeableHeap<ELTTYPE> otherHeap)
          Merge this heap with otherHeap, destroying otherHeap in the process.
 
Methods inherited from interface structure.PriorityQueue
add, clear, getFirst, isEmpty, remove, size
 

Method Detail

merge

void merge(MergeableHeap<ELTTYPE> otherHeap)
Merge this heap with otherHeap, destroying otherHeap in the process.

Parameters:
otherHeap - Heap to be merged into this heap.
Post:
This heap contains all of the elements formerly contained by otherHeap. otherHeap is destroyed in in the process.