Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/DataType/Sort/MaxHeap.hpp

Go to the documentation of this file.
00001 // MaxHeap.hpp - Interface of a max heap class
00002 
00003 #ifndef __J2K__Sort__MaxHeap_HPP__
00004 #define __J2K__Sort__MaxHeap_HPP__
00005 
00006 #include <j2k/DataType/Const.hpp>
00007 #include <j2k/DataType/Sort/Sort.hpp>
00008 
00009 class MaxHeap {                // Max-heap class
00010 public:
00011   MaxHeap( Elem*, int, int );  // Constructor
00012 
00013   int  heapsize()      const;  // Return current size of the heap
00014   bool isLeaf(int)     const;  // TRUE if pos is a leaf position
00015   int  leftchild(int)  const;  // Return position for left child
00016   int  rightchild(int) const;  // Return position for right child
00017   int  parent(int) const;      // Return position for parent of pos
00018   void insert(const Elem);     // Insert value into the maxheap
00019   Elem removemax();            // Remove maximum value
00020   Elem remove(int);            // Remove value at specified position
00021   void buildMaxHeap();         // Heapify contents of Heap
00022 
00023 private:
00024   Elem* Heap;                  // Pointer to the heap array
00025   int   size;                  // Maximum size of the heap
00026   int   n;                     // Number of elements now in the heap
00027   void  siftdown(int);         // Put an element in its correct place
00028 };
00029 
00030 #endif // End of MaxHeap.hpp

Generated on Sun Oct 14 18:46:18 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001