labelRangesI.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-2021 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 Foam::labelRanges::labelRanges(const label nElem)
32:
34{}
35
36
37// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
38
39inline constexpr Foam::labelRanges::const_iterator::
40const_iterator
41(
42 const labelRanges* list,
43 const label i
45:
46 list_(list),
47 index_(i),
48 subIndex_(0)
49{}
50
51
53operator*() const
54{
55 return (*list_)[index_][subIndex_];
56}
57
58
62{
63 if (++subIndex_ >= (*list_)[index_].size())
64 {
65 // Move to the next range
66 ++index_;
67 subIndex_ = 0;
68 }
69
70 return *this;
71}
72
73
76operator++(int)
77{
78 const_iterator old(*this);
79 this->operator++();
80 return old;
81}
82
83
84inline constexpr bool
87(
88 const const_iterator& iter
89) const noexcept
90{
91 return
92 (
93 index_ == iter.index_
94 && subIndex_ == iter.subIndex_
95 );
96}
97
98
99inline constexpr bool
101operator!=
102(
103 const const_iterator& iter
104) const noexcept
105{
106 return !(*this == iter);
107}
108
109
110// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111
114{
115 return const_iterator(this);
116}
117
118
121{
122 return const_iterator(this, this->size());
123}
124
125
128{
129 return const_iterator(this);
130}
131
132
135{
136 return const_iterator(this, this->size());
137}
138
139
140inline bool Foam::labelRanges::found(const label value) const
141{
142 for
143 (
144 const labelRange& range
145 : static_cast<const StorageContainer&>(*this)
146 )
147 {
148 if (range.found(value))
149 {
150 return true;
151 }
152 }
153
154 return false;
155}
156
157
158// ************************************************************************* //
scalar range
bool found
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
edgeFaceCirculator & operator++()
Step to next face. Uses no edge addressing!
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
friend forceSuSp operator*(const forceSuSp &susp1, const forceSuSp &susp2)
Addition.
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
Forward input iterator with const access.
Definition: labelRanges.H:118
A list of labelRange.
Definition: labelRanges.H:62
labelRanges()=default
Default construct.
const_iterator cbegin() const noexcept
A const_iterator set to the beginning of the list.
Definition: labelRangesI.H:113
const_iterator begin() const noexcept
A const_iterator set to the beginning of the list.
Definition: labelRangesI.H:127
const const_iterator cend() const noexcept
A const_iterator set to beyond the end of the list.
Definition: labelRangesI.H:120
const const_iterator end() const noexcept
A const_iterator set to beyond the end of the list.
Definition: labelRangesI.H:134
const direction noexcept
Definition: Scalar.H:223