libdrmconf 0.12.1
A library to program DMR radios.
Loading...
Searching...
No Matches
ranges.hh
1#ifndef RANGES_HH
2#define RANGES_HH
3
4#include <initializer_list>
5#include "interval.hh"
6#include "frequency.hh"
7
12template <class T>
13class Range
14{
15public:
17 inline T map(const T &n) const {
18 if (n < lower)
19 return lower;
20 if (upper < n)
21 return upper;
22 return n;
23 }
24
26 inline bool contains(const T &n) const {
27 return ((lower<n) || (lower==n)) && ((n<upper) || (n==upper));
28 }
29
30public:
33};
34
35
42
43#endif // RANGES_HH
Simple range class representing some range in some data type.
Definition ranges.hh:14
T upper
Specifies the upper bound.
Definition ranges.hh:32
T lower
Specifies the lower bound.
Definition ranges.hh:31
bool contains(const T &n) const
Checks, if the given value lays within the range.
Definition ranges.hh:26
T map(const T &n) const
Maps a given value onto the range.
Definition ranges.hh:17