Lolly 1.4.27
Loading...
Searching...
No Matches
minmax.hpp
Go to the documentation of this file.
1/** \file minmax.hpp
2 * \copyright GPLv3
3 * \details defines basic type aliases and min/max function for these types.
4 * \author Joris van der Hoeven
5 * \date 1999
6 */
7
8#pragma once
9
10typedef int SI;
11typedef unsigned int SN;
12typedef short HI;
13typedef unsigned short HN;
14typedef char QI;
15typedef unsigned char QN;
16typedef long long int DI;
17typedef unsigned long long int DN;
18
19/**
20 * @brief Returns the minimum of two signed integers.
21 *
22 * @param i The first integer.
23 * @param j The second integer.
24 * @return The smaller of the two integers.
25 */
26inline SI
27min (SI i, SI j) {
28 if (i < j) return i;
29 else return j;
30}
31
32/**
33 * @brief Returns the maximum of two signed integers.
34 *
35 * @param i The first integer.
36 * @param j The second integer.
37 * @return The larger of the two integers.
38 */
39inline SI
40max (SI i, SI j) {
41 if (i > j) return i;
42 else return j;
43}
44
45/**
46 * @brief Returns the minimum of two signed integers.
47 *
48 * @param i The first integer.
49 * @param j The second integer.
50 * @return The smaller of the two integers.
51 */
52inline DI
53min (DI i, DI j) {
54 if (i < j) return i;
55 else return j;
56}
57
58/**
59 * @brief Returns the maximum of two signed integers.
60 *
61 * @param i The first integer.
62 * @param j The second integer.
63 * @return The larger of the two integers.
64 */
65inline DI
66max (DI i, DI j) {
67 if (i > j) return i;
68 else return j;
69}
70
71/**
72 * @brief Returns the minimum of two doubles.
73 *
74 * @param i The first double.
75 * @param j The second double.
76 * @return The smaller of the two doubles.
77 */
78inline double
79min (double i, double j) {
80 if (i < j) return i;
81 else return j;
82}
83
84/**
85 * @brief Returns the maximum of two doubles.
86 *
87 * @param i The first double.
88 * @param j The second double.
89 * @return The larger of the two doubles.
90 */
91inline double
92max (double i, double j) {
93 if (i > j) return i;
94 else return j;
95}
The list class represents a linked list.
Definition list.hpp:48
short HI
Definition minmax.hpp:12
SI min(SI i, SI j)
Returns the minimum of two signed integers.
Definition minmax.hpp:27
SI max(SI i, SI j)
Returns the maximum of two signed integers.
Definition minmax.hpp:40
unsigned short HN
Definition minmax.hpp:13
long long int DI
Definition minmax.hpp:16
char QI
Definition minmax.hpp:14
unsigned long long int DN
Definition minmax.hpp:17
unsigned int SN
Definition minmax.hpp:11
int SI
Definition minmax.hpp:10
unsigned char QN
Definition minmax.hpp:15