labelRangeI.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31inline constexpr Foam::labelRange::labelRange() noexcept
32:
33 IntRange<label>()
34{}
35
36
37inline constexpr Foam::labelRange::labelRange(const label len) noexcept
38:
40{}
41
42
44(
45 const label beg,
46 const label len
48:
49 IntRange<label>(beg, len)
50{
51 clampSize();
52}
53
54
56(
57 const label beg,
58 const label len,
59 const bool adjustStart
61:
62 IntRange<label>(beg, len)
63{
64 if (adjustStart)
65 {
66 adjust(); // Eliminate negative start, adjust size accordingly
67 }
68 else
69 {
70 clampSize();
71 }
72}
73
74
75// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76
77inline Foam::label Foam::labelRange::min() const noexcept
78{
79 return start();
80}
81
82
83inline Foam::label Foam::labelRange::max() const noexcept
84{
85 return last();
86}
87
88
89inline Foam::label Foam::labelRange::before() const noexcept
90{
92}
93
94
95inline Foam::label Foam::labelRange::after() const noexcept
96{
98}
99
100
102(
103 const label beg,
104 const label len,
105 const bool adjustStart
106) noexcept
107{
108 reset(beg, len);
109
110 if (adjustStart)
111 {
112 adjust(); // Eliminate negative start, adjust size accordingly
113 }
114 else
115 {
116 clampSize();
117 }
118}
119
120
121// ************************************************************************* //
An interval of (signed) integers defined by a start and a size.
Definition: IntRange.H:64
IntType rend_value() const noexcept
The value 1 before the start of the range.
Definition: IntRangeI.H:457
IntType end_value() const noexcept
The value 1 beyond the end of the range.
Definition: IntRangeI.H:464
void reset()
Reset to defaults.
constexpr labelRange() noexcept
Default construct an empty range (0,0)
Definition: labelRangeI.H:31
label max() const noexcept
The (inclusive) upper value of the range - same as last()
Definition: labelRangeI.H:83
label before() const noexcept
The value before the start of the range.
Definition: labelRangeI.H:89
label min() const noexcept
The (inclusive) lower value of the range - same as first(), start()
Definition: labelRangeI.H:77
label after() const noexcept
The value after the last element in the range.
Definition: labelRangeI.H:95
const direction noexcept
Definition: Scalar.H:223