Gator Library
An implementation of the Red-Black Tree and Priority queue data structure in C++.
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
pq_reservation Class Reference

A priority queue implementation for reservations.This class represents a priority queue that stores reservations. Reservations are stored in a heap data structure, where the highest priority reservation is always at the top. Reservations are ordered based on their priority. More...

#include <priority_queue.hpp>

Collaboration diagram for pq_reservation:
Collaboration graph

Public Member Functions

void push (reservation newReservation)
 Push a new reservation into the priority queue.
 
void pop ()
 Remove the highest priority reservation from the priority queue.
 
reservation top ()
 Get the highest priority reservation from the priority queue.
 
bool empty ()
 Check if the priority queue is empty.
 
int size ()
 Get the size of the priority queue.
 
 pq_reservation ()
 Construct a new pq_reservation object.
 
 ~pq_reservation ()
 Destroy the pq_reservation object.
 

Private Member Functions

void heapify (int index)
 Heapify the heap starting from the given index.
 

Private Attributes

std::vector< reservationheap
 

Detailed Description

A priority queue implementation for reservations.

This class represents a priority queue that stores reservations. Reservations are stored in a heap data structure, where the highest priority reservation is always at the top. Reservations are ordered based on their priority.

Constructor & Destructor Documentation

◆ pq_reservation()

pq_reservation::pq_reservation ( )

Construct a new pq_reservation object.

This is the constructor for the pq_reservation class.

◆ ~pq_reservation()

pq_reservation::~pq_reservation ( )

Destroy the pq_reservation object.

This is the destructor for the pq_reservation class.

Member Function Documentation

◆ empty()

bool pq_reservation::empty ( )

Check if the priority queue is empty.

This function checks if the priority queue is empty.

Returns
True if the priority queue is empty, false otherwise.
Here is the caller graph for this function:

◆ heapify()

void pq_reservation::heapify ( int  index)
private

Heapify the heap starting from the given index.

This function rearranges the elements in the heap to maintain the heap property. It compares the element at the given index with its children and swaps them if necessary.

Parameters
indexThe index to start heapifying from.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pop()

void pq_reservation::pop ( )

Remove the highest priority reservation from the priority queue.

This function removes the highest priority reservation from the priority queue and maintains the heap property.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push()

void pq_reservation::push ( reservation  newReservation)

Push a new reservation into the priority queue.

This function adds a new reservation to the priority queue and maintains the heap property.

Parameters
newReservationThe reservation to be added.
Here is the caller graph for this function:

◆ size()

int pq_reservation::size ( )

Get the size of the priority queue.

This function returns the number of reservations in the priority queue.

Returns
The size of the priority queue.

◆ top()

reservation pq_reservation::top ( )

Get the highest priority reservation from the priority queue.

This function returns the highest priority reservation from the priority queue without removing it.

Returns
The highest priority reservation.
Here is the caller graph for this function:

Member Data Documentation

◆ heap

std::vector<reservation> pq_reservation::heap
private

The heap storing the reservations.


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