33 #ifndef __H__UG__LIB_ALGEBRA__AMG_SOLVER__MAXHEAP_H__
34 #define __H__UG__LIB_ALGEBRA__AMG_SOLVER__MAXHEAP_H__
102 for(
size_t i=0; i<n; i++)
m_heap[i] = -1;
136 if(!
is_in(i))
return;
171 if(!
is_in(i))
return;
188 std::cout <<
"maxheap, size = " <<
m_size <<
", height = " <<
m_height << std::endl;
229 const T &t =
m_arr[i];
250 int parentpos = (
p == 0 ? 0 : (
p+1)/2 -1);
updateable priority queue class. unlike most PQ implementations, we need a method to inform the PQ of...
Definition: maxheap.h:50
size_t height() const
returns nr of elements in the heap.
Definition: maxheap.h:204
void upheap(int i)
Definition: maxheap.h:213
bool is_in(size_t i)
Definition: maxheap.h:178
void downheap(int i)
Definition: maxheap.h:222
void insert_item(int i)
Definition: maxheap.h:120
int get_max() const
returns the index in m_arr of maximal element of the heap
Definition: maxheap.h:158
void update(int i)
update the heap position of array element i (m_arr[i]) use this method if you have changed the value ...
Definition: maxheap.h:169
maxheap(const std::vector< T > &v)
Definition: maxheap.h:75
void print() const
Definition: maxheap.h:186
int leftchild(int index) const
Definition: maxheap.h:260
void reset()
Definition: maxheap.h:112
size_t m_size
Definition: maxheap.h:303
const T * m_arr
Definition: maxheap.h:299
stdvector< int > m_heap
Definition: maxheap.h:300
maxheap()
Definition: maxheap.h:55
size_t m_height
Definition: maxheap.h:302
void create(size_t n, const T *arr_)
creates the heap on a external array arr_[0]..arr_[n-1]
Definition: maxheap.h:91
maxheap(size_t n, const T *arr_)
Definition: maxheap.h:67
void remove(int i)
removes index i in m_arr
Definition: maxheap.h:134
~maxheap()
deconstructor
Definition: maxheap.h:83
void myswap(int i, int j)
Definition: maxheap.h:286
maxheap(const maxheap< T > *other)
void create(const std::vector< T > &v)
Definition: maxheap.h:106
stdvector< int > m_posinheap
Definition: maxheap.h:301
int rightchild(int index) const
Definition: maxheap.h:274
size_t arr_size() const
returns size of external array
Definition: maxheap.h:198
int parent(int index) const
Definition: maxheap.h:247
int remove_max()
returns the index in m_arr of maximal element of the m_heap and removes it from the m_heap
Definition: maxheap.h:148
#define UG_ASSERT(expr, msg)
Definition: assert.h:70