Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
Compare< S, T, E > Class Template Reference

Comparator class for priority queue. More...

Public Member Functions

bool operator() (tuple< S, T, E, double, double, double > &t1, tuple< S, T, E, double, double, double > &t2)
 A comparator function that checks whether to swap the two tuples or not. to https://www.geeksforgeeks.org/comparator-class-in-c-with-examples/ for detailed description of comparator.
 

Detailed Description

template<typename S, typename T, typename E>
class Compare< S, T, E >

Comparator class for priority queue.

Template Parameters
SData type of Process ID
TData type of Arrival time
EData type of Burst time

Member Function Documentation

◆ operator()()

template<typename S , typename T , typename E >
bool Compare< S, T, E >::operator() ( tuple< S, T, E, double, double, double > & t1,
tuple< S, T, E, double, double, double > & t2 )
inline

A comparator function that checks whether to swap the two tuples or not. to https://www.geeksforgeeks.org/comparator-class-in-c-with-examples/ for detailed description of comparator.

Parameters
t1First tuple
t2Second tuple
Returns
true if the tuples SHOULD be swapped
false if the tuples SHOULDN'T be swapped
76 {
77 // Compare arrival times
78 if (get<1>(t2) < get<1>(t1)) {
79 return true;
80 }
81 // If arrival times are same, then compare Process IDs
82 else if (get<1>(t2) == get<1>(t1)) {
83 return get<0>(t2) < get<0>(t1);
84 }
85 return false;
86 }

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