⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heap.h

📁 Data Abstraction & Problem Solving with C++源码
💻 H
字号:
// *********************************************************// Header file Heap.h for the ADT heap.// *********************************************************// Must define MAX_HEAP before compilation//const int MAX_HEAP = maximum-size-of-heap;const int MAX_HEAP = 10;#include "HeapException.h"  #include "KeyedItem.h"  // definition of KeyedItemtypedef KeyedItem HeapItemType;class Heap{public:   Heap();  // default constructor   // copy constructor and destructor are   // supplied by the compiler// Heap operations:   virtual bool heapIsEmpty() const;   // Determines whether a heap is empty.   // Precondition: None.   // Postcondition: Returns true if the heap is empty;   // otherwise returns false.   virtual void heapInsert(const HeapItemType& newItem)      throw(HeapException);   // Inserts an item into a heap.   // Precondition: newItem is the item to be inserted.   // Postcondition: If the heap was not full, newItem is   // in its proper position; otherwise HeapException is   // thrown.   virtual void heapDelete(HeapItemType& rootItem)      throw(HeapException);   // Retrieves and deletes the item in the root of a heap.   // This item has the largest search key in the heap.   // Precondition: None.   // Postcondition: If the heap was not empty, rootItem    // is the retrieved item, the item is deleted from the   // heap. However, if the heap is empty, removal is   // impossible and the function throws HeapException.protected:   void heapRebuild(int root);   // Converts the semiheap rooted at index root    // into a heap.private:   HeapItemType items[MAX_HEAP];  // array of heap items   int          size;             // number of heap items};  // end class// End of header file.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -