# Algorithms_in_C++: Compare< S, T, E > Class Template Reference

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. More...

## Detailed Description

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

Comparator class for priority queue.

Template Parameters

  S | Data type of Process ID
  T | Data type of Arrival time
  E | Data 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

  t1 | First tuple
  t2 | Second tuple

Returns
  true if the tuples SHOULD be swapped
  false if the tuples SHOULDN'T be swapped

{
// Compare arrival times
if (get<1>(t2) < get<1>(t1)) {
return true;
}
// If arrival times are same, then compare Process IDs
else if (get<1>(t2) == get<1>(t1)) {
return get<0>(t2) < get<0>(t1);
}
return false;
}

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

- cpu_scheduling_algorithms/fcfs_scheduling.cpp