|
CPPDescent 80d9539
(with uncommitted changes)
A C++ KNN-Graph creation library
|
ADT Priority Queue. More...
#include <ADTPQueue.hpp>
Public Member Functions | |
| PQueue (CompareFunc compare, DestroyFunc destroyValue, Vector *values) | |
| Construct a new PQueue object. | |
| ~PQueue () | |
| Destroy the PQueue object. | |
| int | getSize () |
| Get the size of the priority queue. | |
| Pointer | getMax () |
| Get the max element of the queue. | |
| Pointer | getMin () |
| Get the min element of the queue. | |
| void | insert (Pointer value) |
| Insert a new element to the queue. | |
| void | removeMax () |
| Remove the max of the queue. | |
| DestroyFunc | setDestroyValue (DestroyFunc destroyValue) |
| Set the Destroy Value object. | |
| void | remove (Pointer value, CompareFunc compare) |
| Finds (using the given compare function) and removes the node with the given value. | |
| int | find (Pointer value, CompareFunc compare) |
| Finds the given value in the priority queue and returns its nodeId. | |
| Vector * | toVector () |
| Returns all the elements as a vector. | |
| Pointer | nodeValue (int nodeId) |
| void | nodeSwap (int nodeId1, int nodeId2) |
| void | bubbleUp (int nodeId) |
| void | bubbleDown (int nodeId) |
| void | naiveHeapify (Vector *values) |
ADT Priority Queue.
| PQueue::PQueue | ( | CompareFunc | compare, |
| DestroyFunc | destroyValue, | ||
| Vector * | values | ||
| ) |
Construct a new PQueue object.
Uses the compare function to compare its elements.
If destroyValue != nullptr, the destroyValue function is called upon removal of an element.
If values != nullptr, then the priority queue will be initialized with the values of the vector values.
| compare | |
| destroyValue | |
| values |
| PQueue::~PQueue | ( | ) |
Destroy the PQueue object.
| int PQueue::find | ( | Pointer | value, |
| CompareFunc | compare | ||
| ) |
Finds the given value in the priority queue and returns its nodeId.
| value | The value we want to find. |
| compare | Compare function to use. |
| Pointer PQueue::getMax | ( | ) |
Get the max element of the queue.
| Pointer PQueue::getMin | ( | ) |
Get the min element of the queue.
| int PQueue::getSize | ( | ) |
Get the size of the priority queue.
| void PQueue::insert | ( | Pointer | value | ) |
Insert a new element to the queue.
| value | The value of the new element to be inserted. |
| void PQueue::remove | ( | Pointer | value, |
| CompareFunc | compare | ||
| ) |
Finds (using the given compare function) and removes the node with the given value.
| value | The value we want to remove. |
| compare | Compare function to use for finding the node we want to remove. |
| void PQueue::removeMax | ( | ) |
Remove the max of the queue.
| DestroyFunc PQueue::setDestroyValue | ( | DestroyFunc | destroyValue | ) |
Set the Destroy Value object.
| destroyValue |
|
inline |
Returns all the elements as a vector.