|
cgv
|
IndexHeap is a heap that allows changing of the elements. More...
#include <dynamic_priority_queue.h>
Classes | |
| struct | extended_element |
| store per element, whether it is empty and a link to the next empty element or to the heap location More... | |
Public Types | |
| typedef T | element_type |
Public Member Functions | |
| dynamic_priority_queue () | |
| empty construction | |
| void | clear () |
| remove all elements | |
| bool | empty () const |
| check if heap is empty | |
| size_t | size () const |
| return the number of elements in the heap | |
| size_t | size_of_element_container () const |
| return the number of elements in the heap | |
queue interface | |
| unsigned int | top () const |
| return the top element | |
| void | pop () |
| remove top element | |
| int | extract () |
| extract top element | |
dynamic element access | |
| bool | is_empty (unsigned int idx) const |
| const element_type & | operator[] (unsigned int idx) const |
| element_type & | operator[] (unsigned int idx) |
| unsigned int | insert (const element_type &e) |
| insert the given element and return its index in the element container | |
| void | update (unsigned int idx) |
| update after a change to the predicate | |
| void | remove (unsigned int idx) |
| remove element at location idx | |
Protected Member Functions | |
| bool | valid (unsigned int hp) const |
| check if a position is outside of range | |
| void | updateLink (unsigned int hp) |
| make sure that the link for hp is ok | |
| bool | isBetter (unsigned int hp1, unsigned int hp2) const |
| check if hp1 is less than hp2, if true, exchange elements | |
| bool | exchangeIfBetter (unsigned int hp1, unsigned int hp2) |
| check if hp1 is less than hp2, if true, exchange elements | |
| void | heapify (unsigned int hp) |
| void | move (unsigned int hp1, unsigned int hp2) |
| move one element to another position, that should be empty | |
| void | removeHeap (unsigned int hp) |
| remove an element on a certain heap pos | |
| void | positionDownward (unsigned int &hp) |
| move an element downward to the correct position | |
| bool | positionUpward (unsigned int &hp) |
| move an element upward to the correct position | |
Protected Attributes | |
| std::vector< extended_element > | elements |
| container for elements | |
| int | last_empty_element |
| store index of last empty element or -1 if there is non | |
| std::vector< unsigned int > | heap |
| store indices to the elements on the heap | |
IndexHeap is a heap that allows changing of the elements.
Definition at line 9 of file dynamic_priority_queue.h.
| typedef T cgv::data::dynamic_priority_queue< T >::element_type |
Definition at line 12 of file dynamic_priority_queue.h.
|
inline |
empty construction
Definition at line 90 of file dynamic_priority_queue.h.
References last_empty_element.
|
inline |
remove all elements
Definition at line 92 of file dynamic_priority_queue.h.
References elements, heap, and last_empty_element.
|
inline |
|
inlineprotected |
check if hp1 is less than hp2, if true, exchange elements
Definition at line 36 of file dynamic_priority_queue.h.
References heap, isBetter(), and updateLink().
Referenced by positionDownward(), and positionUpward().
|
inline |
extract top element
Definition at line 107 of file dynamic_priority_queue.h.
|
inlineprotected |
Definition at line 47 of file dynamic_priority_queue.h.
|
inline |
insert the given element and return its index in the element container
Definition at line 123 of file dynamic_priority_queue.h.
References elements, heap, last_empty_element, positionUpward(), and updateLink().
|
inline |
Definition at line 118 of file dynamic_priority_queue.h.
|
inlineprotected |
check if hp1 is less than hp2, if true, exchange elements
Definition at line 32 of file dynamic_priority_queue.h.
References elements, and heap.
Referenced by exchangeIfBetter(), and positionDownward().
|
inlineprotected |
move one element to another position, that should be empty
Definition at line 49 of file dynamic_priority_queue.h.
References heap, and updateLink().
Referenced by removeHeap().
|
inline |
Definition at line 121 of file dynamic_priority_queue.h.
|
inline |
Definition at line 120 of file dynamic_priority_queue.h.
|
inline |
remove top element
Definition at line 105 of file dynamic_priority_queue.h.
References remove(), and top().
Referenced by extract().
|
inlineprotected |
move an element downward to the correct position
Definition at line 66 of file dynamic_priority_queue.h.
References exchangeIfBetter(), isBetter(), and valid().
|
inlineprotected |
move an element upward to the correct position
Definition at line 77 of file dynamic_priority_queue.h.
References exchangeIfBetter().
Referenced by insert().
|
inline |
remove element at location idx
Definition at line 154 of file dynamic_priority_queue.h.
References elements, last_empty_element, and removeHeap().
Referenced by pop().
|
inlineprotected |
remove an element on a certain heap pos
Definition at line 55 of file dynamic_priority_queue.h.
Referenced by remove().
|
inline |
return the number of elements in the heap
Definition at line 96 of file dynamic_priority_queue.h.
References heap.
|
inline |
return the number of elements in the heap
Definition at line 98 of file dynamic_priority_queue.h.
References elements.
|
inline |
|
inline |
update after a change to the predicate
Definition at line 148 of file dynamic_priority_queue.h.
References elements.
|
inlineprotected |
make sure that the link for hp is ok
Definition at line 30 of file dynamic_priority_queue.h.
References elements, and heap.
Referenced by exchangeIfBetter(), insert(), and move().
|
inlineprotected |
check if a position is outside of range
Definition at line 28 of file dynamic_priority_queue.h.
References heap.
Referenced by positionDownward().
|
protected |
container for elements
Definition at line 22 of file dynamic_priority_queue.h.
Referenced by clear(), insert(), isBetter(), remove(), size_of_element_container(), update(), and updateLink().
|
protected |
store indices to the elements on the heap
Definition at line 26 of file dynamic_priority_queue.h.
Referenced by clear(), empty(), exchangeIfBetter(), insert(), isBetter(), move(), removeHeap(), size(), top(), updateLink(), and valid().
|
protected |
store index of last empty element or -1 if there is non
Definition at line 24 of file dynamic_priority_queue.h.
Referenced by clear(), dynamic_priority_queue(), insert(), and remove().