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 -------------------------------------------------------------------------------
11 License
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 
31 inline constexpr Foam::labelRange::labelRange() noexcept
32 :
33  IntRange<label>()
34 {}
35 
36 
37 inline constexpr Foam::labelRange::labelRange(const label len) noexcept
38 :
39  IntRange<label>(len)
40 {}
41 
42 
44 (
45  const label beg,
46  const label len
47 ) noexcept
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
60 ) noexcept
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 
77 inline Foam::label Foam::labelRange::min() const noexcept
78 {
79  return start();
80 }
81 
82 
83 inline Foam::label Foam::labelRange::max() const noexcept
84 {
85  return last();
86 }
87 
88 
89 inline Foam::label Foam::labelRange::before() const noexcept
90 {
92 }
93 
94 
95 inline Foam::label Foam::labelRange::after() const noexcept
96 {
98 }
99 
100 
101 inline void Foam::labelRange::reset
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 // ************************************************************************* //
Foam::IntRange::rend_value
IntType rend_value() const noexcept
The value 1 before the start of the range.
Definition: IntRangeI.H:457
Foam::labelRange::before
label before() const noexcept
The value before the start of the range.
Definition: labelRangeI.H:89
Foam::IntRange
An interval of (signed) integers defined by a start and a size.
Definition: IntRange.H:63
Foam::labelRange::reset
void reset(const label beg, const label end, const bool adjustStart) noexcept
Reset start and length, enforces non-negative size.
Definition: labelRangeI.H:102
Foam::labelRange::after
label after() const noexcept
The value after the last element in the range.
Definition: labelRangeI.H:95
Foam::labelRange::max
label max() const noexcept
The (inclusive) upper value of the range - same as last()
Definition: labelRangeI.H:83
Foam::IntRange::end_value
IntType end_value() const noexcept
The value 1 beyond the end of the range.
Definition: IntRangeI.H:464
reset
meshPtr reset(new Foam::fvMesh(Foam::IOobject(regionName, runTime.timeName(), runTime, Foam::IOobject::MUST_READ), false))
Foam::labelRange::labelRange
constexpr labelRange() noexcept
Default construct an empty range (0,0)
Definition: labelRangeI.H:31
Foam::labelRange::min
label min() const noexcept
The (inclusive) lower value of the range - same as first(), start()
Definition: labelRangeI.H:77