CPPDescent 80d9539 (with uncommitted changes)
A C++ KNN-Graph creation library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
PQueue Class Reference

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.
 
VectortoVector ()
 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)
 

Detailed Description

ADT Priority Queue.

Constructor & Destructor Documentation

◆ PQueue()

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.

Parameters
compare
destroyValue
values

◆ ~PQueue()

PQueue::~PQueue ( )

Destroy the PQueue object.

Member Function Documentation

◆ find()

int PQueue::find ( Pointer  value,
CompareFunc  compare 
)

Finds the given value in the priority queue and returns its nodeId.

Parameters
valueThe value we want to find.
compareCompare function to use.
Returns
int

◆ getMax()

Pointer PQueue::getMax ( )

Get the max element of the queue.

Returns
Pointer A generic pointer to the max element.

◆ getMin()

Pointer PQueue::getMin ( )

Get the min element of the queue.

Returns
Pointer A generic pointer to the min element.

◆ getSize()

int PQueue::getSize ( )

Get the size of the priority queue.

Returns
int

◆ insert()

void PQueue::insert ( Pointer  value)

Insert a new element to the queue.

Parameters
valueThe value of the new element to be inserted.

◆ remove()

void PQueue::remove ( Pointer  value,
CompareFunc  compare 
)

Finds (using the given compare function) and removes the node with the given value.

Parameters
valueThe value we want to remove.
compareCompare function to use for finding the node we want to remove.

◆ removeMax()

void PQueue::removeMax ( )

Remove the max of the queue.

◆ setDestroyValue()

DestroyFunc PQueue::setDestroyValue ( DestroyFunc  destroyValue)

Set the Destroy Value object.

Parameters
destroyValue
Returns
DestroyFunc

◆ toVector()

Vector * PQueue::toVector ( )
inline

Returns all the elements as a vector.

Returns
Vector*

The documentation for this class was generated from the following files: