structure5
Interface MergeableHeap<E extends Comparable<E>>

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

public interface MergeableHeap<E extends Comparable<E>>
extends PriorityQueue<E>

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 structure.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<E> otherHeap)
          Merge this heap with otherHeap, destroying otherHeap in the process.
 
Methods inherited from interface structure5.PriorityQueue
add, clear, getFirst, isEmpty, remove, size
 

Method Detail

merge

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

Parameters:
otherHeap - Heap to be merged into this heap.