TheAlgorithms/C++ 1.0.0
All the 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

Definition at line 63 of file fcfs_scheduling.cpp.

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

Definition at line 76 of file fcfs_scheduling.cpp.

77 {
78 // Compare arrival times
79 if (get<1>(t2) < get<1>(t1)) {
80 return true;
81 }
82 // If arrival times are same, then compare Process IDs
83 else if (get<1>(t2) == get<1>(t1)) {
84 return get<0>(t2) < get<0>(t1);
85 }
86 return false;
87 }

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