Heap

From CometPublic

Jump to: navigation, search

[edit] Heap

This class implements a heap of items and is declared with statements like

  heap{int -> string} h();

With this declaration, h is an instance of the class heap that has the following API,

 class heap<K,V> {
      heap();                   /** Creates an empty heap */
      bool empty();             /** Checks whether the heap is empty */
      void insert(K,V);         /** inserts a new key/value pair */
      K getKeyMin();            /** retrieves the key of the smallest pair */
      V getDataMin();           /** retrieves the key of the largest pair */
      void pop();               /** extracts the smallest pair */
      void reset();             /** wipes the heap */
 }