ug4
|
updateable priority queue class. this priority queue works on an external array of elements T. More...
#include <boxsort.h>
Public Member Functions | |
size_t | arr_size () const |
returns size of external array More... | |
BoxPriorityQueue () | |
BoxPriorityQueue (const std::vector< T > &v) | |
BoxPriorityQueue (size_t n, const T *arr_) | |
void | create (const std::vector< T > &v) |
void | create (size_t n, const T *arr_) |
creates the queue on a external array arr_[0]..arr_[n-1] More... | |
size_t | get_max () const |
returns the index in m_arr of maximal element of the heap More... | |
size_t | height () const |
returns nr of elements in the heap. More... | |
void | insert_item (size_t i) |
bool | is_in (size_t i) |
void | remove (size_t i) |
removes index i in arr More... | |
size_t | remove_max () |
returns the index in arr of maximal element of the heap More... | |
void | reset () |
void | update (size_t i) |
~BoxPriorityQueue () | |
deconstructor More... | |
Private Member Functions | |
BoxPriorityQueue (const BoxPriorityQueue< T > &other) | |
void | size_check (size_t i) |
Private Attributes | |
const T * | arr |
stdvector< stdvector< size_t > > | m_box |
size_t | m_height |
stdvector< int > | m_posInBox |
size_t | m_size |
stdvector< size_t > | m_values |
updateable priority queue class. this priority queue works on an external array of elements T.
T | type of elements in the maxheap. Has to support size_t T::get_val() const, and get_val() has to be between 0 and and small number (for example, 500). |
Elements are put in "boxes" depending on their get_val()-value - this makes sorting extremely easy: sorting and accessing is O(1), and inserting is maximal a) creation of enough boxes, and b) inserting into a box, so it is O(maximal get_val()). This algorithm is like a "radical" radix exchange sort.
|
private |
|
inline |
|
inline |
constructor
n | maximal number of elements |
arr_ | array with elements which are to compare. note that non of these are in the queue in the beginning |
References ug::BoxPriorityQueue< T >::create().
|
inline |
References ug::BoxPriorityQueue< T >::create().
|
inline |
deconstructor
|
inline |
returns size of external array
References ug::BoxPriorityQueue< T >::m_size.
Referenced by ug::BoxPriorityQueue< T >::size_check().
|
inline |
References ug::BoxPriorityQueue< T >::create().
|
inline |
creates the queue on a external array arr_[0]..arr_[n-1]
create
References ug::BoxPriorityQueue< T >::arr, ug::BoxPriorityQueue< T >::m_box, ug::BoxPriorityQueue< T >::m_height, ug::BoxPriorityQueue< T >::m_posInBox, ug::BoxPriorityQueue< T >::m_size, and ug::BoxPriorityQueue< T >::m_values.
Referenced by ug::BoxPriorityQueue< T >::BoxPriorityQueue(), and ug::BoxPriorityQueue< T >::create().
|
inline |
returns the index in m_arr of maximal element of the heap
References ug::BoxPriorityQueue< T >::m_box, ug::BoxPriorityQueue< T >::m_height, and UG_ASSERT.
|
inline |
returns nr of elements in the heap.
References ug::BoxPriorityQueue< T >::m_height.
|
inline |
insertItem inserts Item arr[i] (see constructor) into heap
i | index of item in arr |
References ug::BoxPriorityQueue< T >::arr, ug::BOXPRIORITYQUEUE_MAXIMAL_VALUE, ug::get_val(), ug::BoxPriorityQueue< T >::m_box, ug::BoxPriorityQueue< T >::m_height, ug::BoxPriorityQueue< T >::m_posInBox, ug::BoxPriorityQueue< T >::m_values, ug::BoxPriorityQueue< T >::size_check(), and UG_ASSERT.
Referenced by ug::BoxPriorityQueue< T >::update().
|
inline |
References ug::BoxPriorityQueue< T >::m_posInBox.
|
inline |
removes index i in arr
References ug::BoxPriorityQueue< T >::m_box, ug::BoxPriorityQueue< T >::m_height, ug::BoxPriorityQueue< T >::m_posInBox, ug::BoxPriorityQueue< T >::m_values, and ug::BoxPriorityQueue< T >::size_check().
Referenced by ug::BoxPriorityQueue< T >::remove_max(), and ug::BoxPriorityQueue< T >::update().
|
inline |
returns the index in arr of maximal element of the heap
References ug::BoxPriorityQueue< T >::m_box, ug::BoxPriorityQueue< T >::m_height, ug::BoxPriorityQueue< T >::remove(), and UG_ASSERT.
|
inline |
References ug::BoxPriorityQueue< T >::m_box.
|
inlineprivate |
debug print output
References ug::BoxPriorityQueue< T >::arr_size(), and UG_ASSERT.
Referenced by ug::BoxPriorityQueue< T >::insert_item(), and ug::BoxPriorityQueue< T >::remove().
|
inline |
i | index in arr for which to update |
References ug::BoxPriorityQueue< T >::arr, ug::get_val(), ug::BoxPriorityQueue< T >::insert_item(), ug::BoxPriorityQueue< T >::m_posInBox, ug::BoxPriorityQueue< T >::m_values, and ug::BoxPriorityQueue< T >::remove().
|
private |
|
private |
|
private |
|
private |
|
private |
Referenced by ug::BoxPriorityQueue< T >::arr_size(), and ug::BoxPriorityQueue< T >::create().
|
private |