SNAP Library 4.0, Developer Reference
2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Simple heap data structure. More...
#include <gbase.h>
Public Member Functions | |
THeap () | |
THeap (const int &MxVals) | |
THeap (const TCmp &_Cmp) | |
THeap (const TVec< TVal > &Vec) | |
THeap (const TVec< TVal > &Vec, const TCmp &_Cmp) | |
THeap (const THeap &Heap) | |
THeap & | operator= (const THeap &H) |
const TVal & | TopHeap () const |
Returns a reference to the element at the top of the heap (the largest element of the heap). More... | |
void | PushHeap (const TVal &Val) |
Pushes an element Val to the heap. More... | |
TVal | PopHeap () |
Removes the top element from the heap. More... | |
int | Len () const |
Returns the number of elements in the heap. More... | |
bool | Empty () const |
Tests whether the heap is empty. More... | |
const TVec< TVal > & | operator() () const |
Returns a reference to the vector containing the elements of the heap. More... | |
TVec< TVal > & | operator() () |
Returns a reference to the vector containing the elements of the heap. More... | |
void | Add (const TVal &Val) |
Adds an element to the data structure. Heap property is not maintained by Add() and thus after all the elements are added MakeHeap() needs to be called. More... | |
void | MakeHeap () |
Builds a heap from a set of elements. More... | |
Private Member Functions | |
void | PushHeap (const int &First, int HoleIdx, const int &Top, TVal Val) |
void | AdjustHeap (const int &First, int HoleIdx, const int &Len, TVal Val) |
void | MakeHeap (const int &First, const int &Len) |
Private Attributes | |
TCmp | Cmp |
TVec< TVal > | HeapV |
Simple heap data structure.
Data structure provides insertion of elements, and inspection and removal of the top element. It is guaranteed that the top element is the largest element in the heap, where the function object TCmp
is used for comparisons.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Adds an element to the data structure. Heap property is not maintained by Add()
and thus after all the elements are added MakeHeap()
needs to be called.
Definition at line 288 of file gbase.h.
|
private |
Definition at line 322 of file gbase.h.
References Cmp().
Returns the number of elements in the heap.
Definition at line 280 of file gbase.h.
Referenced by THeap< TTriple >::MakeHeap().
|
private |
Definition at line 336 of file gbase.h.
Builds a heap from a set of elements.
Definition at line 290 of file gbase.h.
Referenced by THeap< TTriple >::MakeHeap(), and THeap< TTriple >::THeap().
|
inline |
|
inline |
|
inline |
Removes the top element from the heap.
Definition at line 300 of file gbase.h.
References IAssert.
|
private |
Pushes an element Val
to the heap.
Definition at line 294 of file gbase.h.
|
inline |
Definition at line 258 of file gbase.h.
Referenced by THeap< TTriple >::operator=().
Definition at line 259 of file gbase.h.
Referenced by THeap< TTriple >::Add(), THeap< TTriple >::Empty(), THeap< TTriple >::Len(), THeap< TTriple >::operator()(), THeap< TTriple >::operator=(), and THeap< TTriple >::TopHeap().