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 void Foam::labelRange::reset
78 (
79  const label beg,
80  const label len,
81  const bool adjustStart
82 ) noexcept
83 {
84  reset(beg, len);
85 
86  if (adjustStart)
87  {
88  adjust(); // Eliminate negative start, adjust size accordingly
89  }
90  else
91  {
92  clampSize();
93  }
94 }
95 
96 
97 // ************************************************************************* //
constexpr labelRange() noexcept
Default construct an empty range (0,0)
Definition: labelRangeI.H:24
An interval of (signed) integers defined by a start and a size.
Definition: IntRange.H:59
const direction noexcept
Definition: Scalar.H:258
void reset() noexcept
Reset to zero start and zero size.
Definition: IntRangeI.H:397