Added sorting criteria
This commit is contained in:
parent
e25fbf7a3a
commit
3a0af23bde
2 changed files with 26 additions and 3 deletions
|
|
@ -11,3 +11,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sorting_criteria.h"
|
#include "sorting_criteria.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not `fst` is smaller than or equal to `snd` (ascending order).
|
||||||
|
*
|
||||||
|
* @param fst The value that is supposed being smaller than `snd`.
|
||||||
|
* @param snd The value to compare.
|
||||||
|
* @return True if `fst` is smaller than or equal to `snd`, false otherwise.
|
||||||
|
*/
|
||||||
|
bool is_in_asc_order(int fst, int snd) {
|
||||||
|
return fst <= snd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not `fst` is greater than or equal to `snd` (descending order).
|
||||||
|
*
|
||||||
|
* @param fst The value that is supposed being greater than `snd`.
|
||||||
|
* @param snd The value to compare.
|
||||||
|
* @return True if `fst` is greater than or equal to `snd`, false otherwise.
|
||||||
|
*/
|
||||||
|
bool is_in_desc_order(int fst, int snd) {
|
||||||
|
return fst >= snd;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
* (the values are in order), false otherwise.
|
* (the values are in order), false otherwise.
|
||||||
*/
|
*/
|
||||||
/* Note: Name the pointer type 'criterion_fn' */
|
/* Note: Name the pointer type 'criterion_fn' */
|
||||||
|
typedef bool (*criterion_fn)(int fst, int snd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether or not `fst` is smaller than or equal to `snd` (ascending order).
|
* Determines whether or not `fst` is smaller than or equal to `snd` (ascending order).
|
||||||
|
|
@ -35,15 +36,15 @@
|
||||||
* @param snd The value to compare.
|
* @param snd The value to compare.
|
||||||
* @return True if the criterion is satisfied, false otherwise.
|
* @return True if the criterion is satisfied, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool is_in_asc_order(<params>);
|
bool is_in_asc_order(int fst, int snd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether or not `fst` is larger than or equal to `snd` (descending order).
|
* Determines whether or not `fst` is larger than or equal to `snd` (descending order).
|
||||||
*
|
*
|
||||||
* @param fst The value that is supposed being smaller than `snd`.
|
* @param fst The value that is supposed being greater than `snd`.
|
||||||
* @param snd The value to compare.
|
* @param snd The value to compare.
|
||||||
* @return True if the criterion is satisfied, false otherwise.
|
* @return True if the criterion is satisfied, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool is_in_desc_order(i<params>);
|
bool is_in_desc_order(int fst, int snd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue