|
| PriorityQueue () |
| Create a new empty priority queue with the default capacity. More...
|
|
| PriorityQueue (Size newCapacity) |
| Create a new empty priority queue with the specified initial capacity. More...
|
|
| PriorityQueue (const PriorityQueue< T > &other) |
| Create a copy of an existing priority queue, performing a deep copy. More...
|
|
| ~PriorityQueue () |
| Destroy a priority queue. More...
|
|
PriorityQueue< T > & | operator= (const PriorityQueue< T > &other) |
| Assign this priority queue with the contents of another, performing a deep copy. More...
|
|
Bool | operator== (const PriorityQueue< T > &other) const |
| Return whether or not whether every entry in this queue is equal to another queue's entries. More...
|
|
Bool | operator!= (const PriorityQueue< T > &other) const |
|
void | add (const T &newElement) |
| Add a new element to this priority queue. More...
|
|
void | remove () |
| Remove the largest element from the priority queue. More...
|
|
Bool | remove (const T &element) |
| Remove the element with the specified value from the priority queue. More...
|
|
void | removeAtIndex (SizeType i) |
| Remove the element at the specified index from the priority queue. More...
|
|
void | update (SizeType i) |
| Ensure that the heap is propery ordered after the specified element was changed. More...
|
|
Bool | getIndex (const T &value, SizeType &index) const |
| Get the index of the specified value in this priority queue. More...
|
|
Bool | contains (const T &element) const |
| Return whether or not the specified element is in the priority queue. More...
|
|
T & | getFirst () |
| Return a reference to the largest element in the priority queue. More...
|
|
const T & | getFirst () const |
| Return a const reference to the largest element in the priority queue. More...
|
|
T & | operator[] (SizeType i) |
| Return a reference to the element in this priority queue at the specified index. More...
|
|
const T & | operator[] (SizeType i) const |
| Return a const reference to the element in this priority queue at the specified index. More...
|
|
void | clear () |
| Clear the contents of this priority queue. More...
|
|
void | reset () |
| Clear the contents of this priority queue and reclaim the allocated memory. More...
|
|
void | reset (SizeType newCapacity) |
| Clear the contents of this priority queue and reclaim the allocated memory. More...
|
|
Bool | isEmpty () const |
| Return whether or not the priority queue has any elements. More...
|
|
SizeType | getSize () const |
| Get the number of elements in the priority queue. More...
|
|
SizeType | getCapacity () const |
| Get the current capacity of the priority queue. More...
|
|
template<typename T, typename SizeType = Size, typename AllocatorType = Allocator>
class om::util::PriorityQueue< T, SizeType, AllocatorType >
A class that implements a max-heap-based priority queue.
The class uses an array-based heap where larger elements are stored towards the front. When elements are added or removed from the heap, internal state is kept consistent so that the first item in the queue is the largest. Element comparisons are done using the greater-than operator (>). Therefore, any class that the user wishes to use with this implementation must provide an overloaded greater-than operator.
template<typename T, typename SizeType = Size, typename AllocatorType = Allocator>
Clear the contents of this priority queue and reclaim the allocated memory.
This method performs the same function as the clear() method, but also deallocates the previously allocated internal array. Calling this method is equivalent to assigning a new queue instance to this one.
template<typename T, typename SizeType = Size, typename AllocatorType = Allocator>
Clear the contents of this priority queue and reclaim the allocated memory.
This method performs the same function as the clear() method, but also deallocates the previously allocated internal array and reallocates it to a small initial starting size. Calling this method is equivalent to assigning a new priority queue instance to this one. This version of the reset() method allows the caller to specify the new starting capacity of the queue.
template<typename T, typename SizeType = Size, typename AllocatorType = Allocator>
Return the index of a child elements's parent element given the child element's index.
If the child index is zero, the method returns 0 because this child element is at the top of the heap and has no parent by definition.