Loading...
Searching...
No Matches
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 * * * * * * * * * * * * * * //
32:
33 IntRange<label>()
34{}
35
37inline constexpr Foam::labelRange::labelRange(label len) noexcept
38:
40{}
41
42
43inline Foam::labelRange::labelRange(label beg, label len) noexcept
45 IntRange<label>(beg, len)
46{
47 clampSize();
48}
49
50
52(
53 label beg,
54 label len,
55 bool adjustStart
57:
58 IntRange<label>(beg, len)
59{
60 if (adjustStart)
61 {
62 adjust(); // Eliminate negative start, adjust size accordingly
63 }
64 else
65 {
67 }
68}
69
70
71// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72
74(
75 label beg,
76 label len,
77 bool adjustStart
78) noexcept
79{
80 IntRange<label>::reset(beg, len);
81
82 if (adjustStart)
83 {
84 adjust(); // Eliminate negative start, adjust size accordingly
85 }
86 else
87 {
88 clampSize();
89 }
90}
91
92
94Foam::labelRange::subset0(label len) const
95{
96 return this->subset(0, len);
97}
98
99
100// ************************************************************************* //
An interval of (signed) integers defined by a start and a size.
Definition IntRange.H:69
void reset() noexcept
Definition IntRangeI.H:99
void clampSize() noexcept
Definition IntRangeI.H:136
constexpr IntRange() noexcept
Definition IntRangeI.H:24
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
constexpr labelRange() noexcept
Default construct an empty range (0,0).
Definition labelRangeI.H:24
void adjust() noexcept
Adjust the start to avoid negative indices.
labelRange subset0(label len) const
Calculate the intersection with the given 0/size range.
Definition labelRangeI.H:87
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
const direction noexcept
Definition scalarImpl.H:265