I have been writing this thing for a long time. I wrote the prim algorithm yesterday. STL won't write binary heap yet. It's sad. It will be learned in the future. now, use this one first.
Post: I don't want to talk about it anymore. Liu Xiang is about to start. Let's take a look at his.
// Binaryheap. H -- 2011-08-28-22.57 // purpose: // define a class "binaryheap ". // declare methods of the class, and define element member. # include <iostream> class binaryheap {public: typedef struct node {int startindex; int endindex; int weight;} node; private: node * m_heap; int m_size; int m_currentsize; void m_percolateup (INT index); void m_percolatedown (INT index); Public: binaryheap (INT size = 0 );~ Binaryheap (void); bool isempty (void); bool isfull (void); bool insert (INT startindex, int endindex, int weight ); bool deletemin (node * const pnode );};