OPALX (Object Oriented Parallel Accelerator Library for Exascal)
master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
ValueRange.h
Go to the documentation of this file.
1
//
2
// Class ValueRange
3
//
4
// This class provides functionality to compute the limits of a range of double values.
5
//
6
// Copyright (c) 2021, Christof Metzger-Kraus
7
//
8
// All rights reserved
9
//
10
// This file is part of OPAL.
11
//
12
// OPAL is free software: you can redistribute it and/or modify
13
// it under the terms of the GNU General Public License as published by
14
// the Free Software Foundation, either version 3 of the License, or
15
// (at your option) any later version.
16
//
17
// You should have received a copy of the GNU General Public License
18
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
19
//
20
#ifndef VALUERANGE_H
21
#define VALUERANGE_H
22
23
#include "Utility/Inform.h"
24
25
#include <algorithm>
26
#include <limits>
27
28
template
<
class
T>
29
class
ValueRange
{
30
public
:
31
ValueRange
()
32
:
minValue_m
(
std
::numeric_limits<
T
>::max()),
maxValue_m
(
std
::numeric_limits<
T
>::lowest()) {}
33
34
void
enlargeIfOutside
(
T
value) {
35
minValue_m
= std::min(
minValue_m
, value);
36
maxValue_m
= std::max(
maxValue_m
, value);
37
}
38
bool
isInside
(
T
value)
const
{
return
minValue_m
< value && value <
maxValue_m
; }
39
40
bool
isOutside
(
T
value)
const
{
return
!
isInside
(value); }
41
42
void
print
(Inform& out)
const
{
43
out <<
"Value range between "
<<
minValue_m
<<
" and "
<<
maxValue_m
;
44
}
45
46
private
:
47
T
minValue_m
;
48
T
maxValue_m
;
49
};
50
51
template
<
class
T>
52
Inform&
operator<<
(Inform& out,
ValueRange<T>
const
& range) {
53
range.
print
(out);
54
return
out;
55
}
56
57
#endif
T
double T
Definition
OPALTypes.h:8
operator<<
Inform & operator<<(Inform &out, ValueRange< T > const &range)
Definition
ValueRange.h:52
ValueRange
Definition
ValueRange.h:29
ValueRange::print
void print(Inform &out) const
Definition
ValueRange.h:42
ValueRange::maxValue_m
T maxValue_m
Definition
ValueRange.h:48
ValueRange::isOutside
bool isOutside(T value) const
Definition
ValueRange.h:40
ValueRange::enlargeIfOutside
void enlargeIfOutside(T value)
Definition
ValueRange.h:34
ValueRange::isInside
bool isInside(T value) const
Definition
ValueRange.h:38
ValueRange::ValueRange
ValueRange()
Definition
ValueRange.h:31
ValueRange::minValue_m
T minValue_m
Definition
ValueRange.h:47
std
STL namespace.
src
Structure
ValueRange.h
Generated on Mon Jun 1 2026 10:40:53 for OPALX (Object Oriented Parallel Accelerator Library for Exascal) by
1.9.8