Priority queue implemented as a heap. More...
Public Types | |
typedef TKey | Key |
typedef TKey | Key |
typedef TValue | Value |
typedef TValue | Value |
Public Member Functions | |
void | Init () |
Initializes an empty priority queue. | |
void | Init () |
Initializes an empty priority queue. | |
bool | is_empty () const |
Detects whether this queue is empty. | |
bool | is_empty () const |
Detects whether this queue is empty. | |
Value | Pop () |
Pops and returns the lowest element off the heap. | |
Value | Pop () |
Pops and returns the lowest element off the heap. | |
void | PopOnly () |
Removes the lowest element from the heap. | |
void | PopOnly () |
Removes the lowest element from the heap. | |
void | Put (Key key, Value value) |
Places a value at the specified priority. | |
void | Put (Key key, Value value) |
Places a value at the specified priority. | |
void | set_top (Value v) |
Replaces the top item on the heap. | |
void | set_top (Value v) |
Replaces the top item on the heap. | |
index_t | size () const |
Gets the size of the heap. | |
index_t | size () const |
Gets the size of the heap. | |
Value | top () const |
Gets the value at the top of the heap. | |
Value | top () const |
Gets the value at the top of the heap. | |
Key | top_key () const |
Gets the key at the top of the heap. | |
Key | top_key () const |
Gets the key at the top of the heap. |
Priority queue implemented as a heap.
Note that a heap isn't really a collection, but actually it is just a prioritization data structure. Storing large objects in will incur copy overheads, so Key and Value should probably be either primitives (integers, floats, pointers) or small structures.
Definition at line 53 of file heap.h.
void MinHeap< TKey, TValue >::Init | ( | ) | [inline] |
void MinHeap< TKey, TValue >::Init | ( | ) | [inline] |
Initializes an empty priority queue.
Definition at line 81 of file heap.h.
Referenced by GrainQueue< Grain >::Init().
bool MinHeap< TKey, TValue >::is_empty | ( | ) | const [inline] |
bool MinHeap< TKey, TValue >::is_empty | ( | ) | const [inline] |
Value MinHeap< TKey, TValue >::Pop | ( | ) | [inline] |
Value MinHeap< TKey, TValue >::Pop | ( | ) | [inline] |
Pops and returns the lowest element off the heap.
Definition at line 114 of file heap.h.
Referenced by GrainQueue< Grain >::Pop().
void MinHeap< TKey, TValue >::PopOnly | ( | ) | [inline] |
void MinHeap< TKey, TValue >::PopOnly | ( | ) | [inline] |
Removes the lowest element from the heap.
Simply pops the top value on the queue, without returning it.
Definition at line 128 of file heap.h.
Referenced by MinHeap< double, Grain * >::Pop().
void MinHeap< TKey, TValue >::Put | ( | Key | key, | |
Value | value | |||
) | [inline] |
void MinHeap< TKey, TValue >::Put | ( | Key | key, | |
Value | value | |||
) | [inline] |
Places a value at the specified priority.
key | the priority | |
value | the value associated with the priority |
Definition at line 98 of file heap.h.
Referenced by GrainQueue< Grain >::Put().
void MinHeap< TKey, TValue >::set_top | ( | Value | v | ) | [inline] |
void MinHeap< TKey, TValue >::set_top | ( | Value | v | ) | [inline] |
index_t MinHeap< TKey, TValue >::size | ( | ) | const [inline] |
index_t MinHeap< TKey, TValue >::size | ( | ) | const [inline] |
Gets the size of the heap.
Definition at line 161 of file heap.h.
Referenced by GrainQueue< Grain >::Pop(), and GrainQueue< Grain >::size().
Value MinHeap< TKey, TValue >::top | ( | ) | const [inline] |
Value MinHeap< TKey, TValue >::top | ( | ) | const [inline] |
Key MinHeap< TKey, TValue >::top_key | ( | ) | const [inline] |
Key MinHeap< TKey, TValue >::top_key | ( | ) | const [inline] |