Scheduler Sim
A CPU Scheduling Algorithm Simulator in C++.
Loading...
Searching...
No Matches
MinHeap< T > Class Template Reference

A min heap implementation. More...

#include <min_heap.hpp>

Public Member Functions

 MinHeap (int(*comparator)(const T &a, const T &b))
 Construct a new Min Heap object.
 
 MinHeap (std::vector< T > &vec, int(*comparator)(const T &a, const T &b))
 Construct a new Min Heap object from a vector.
 
 ~MinHeap ()=default
 
void printHeap () const
 
void buildHeap ()
 
void insert (T element)
 
extractMin ()
 
void decreaseKey (size_t index, T element)
 
bool isEmpty () const
 

Detailed Description

template<typename T>
class MinHeap< T >

A min heap implementation.

Template Parameters
TThe type of the elements in the heap

Constructor & Destructor Documentation

◆ MinHeap() [1/2]

template<typename T >
MinHeap< T >::MinHeap ( int(*)(const T &a, const T &b)  comparator)

Construct a new Min Heap object.

Parameters
comparatorThe comparator function to be used for comparing elements

◆ MinHeap() [2/2]

template<typename T >
MinHeap< T >::MinHeap ( std::vector< T > &  vec,
int(*)(const T &a, const T &b)  comparator 
)

Construct a new Min Heap object from a vector.

Parameters
vecThe vector to be converted into a heap
comparatorThe comparator function to be used for comparing elements

◆ ~MinHeap()

template<typename T >
MinHeap< T >::~MinHeap ( )
default

Member Function Documentation

◆ buildHeap()

template<typename T >
void MinHeap< T >::buildHeap ( )

◆ decreaseKey()

template<typename T >
void MinHeap< T >::decreaseKey ( size_t  index,
element 
)

◆ extractMin()

template<typename T >
T MinHeap< T >::extractMin ( )

◆ insert()

template<typename T >
void MinHeap< T >::insert ( element)

◆ isEmpty()

template<typename T >
bool MinHeap< T >::isEmpty ( ) const

◆ printHeap()

template<typename T >
void MinHeap< T >::printHeap ( ) const

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