28 #include <csutil/array.h> 35 class Heap :
protected csArray<T*>
38 using csArray<T*>::Get;
39 using csArray<T*>::Top;
49 return csArray<T*>::GetSize();
57 this->SetSize(
Length() + 1);
61 for( i =
Length()-1; i != 0 && *Get((i-1)/2) > *what; i = (i-1)/2)
62 this->Put(i, this->Get((i-1)/2));
72 T* minElement = this->Get(0);
73 T* lastElement = this->Top();
77 this->Truncate(
Length() - 1);
82 for(i = 0; i * 2 + 1 <
Length(); i = child)
86 if( child !=
Length()-1 && *this->Get(child + 1) < *this->Get(child) )
90 if( *lastElement > *this->Get(child))
91 this->Put(i, this->Get(child));
95 this->Put(i, lastElement);