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 -------------------------------------------------------------------------------
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 Foam::labelRanges::labelRanges(const label nElem)
32 :
33  DynamicList<labelRange>(nElem)
34 {}
35 
36 
37 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
38 
41 (
42  const labelRanges* list,
43  const label i
44 ) noexcept
45 :
46  list_(list),
47  index_(i),
48  subIndex_(0)
49 {}
50 
51 
52 inline Foam::label Foam::labelRanges::const_iterator::
53 operator*() 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 
77 {
78  const_iterator old(*this);
79  this->operator++();
80  return old;
81 }
82 
83 
84 inline constexpr bool
85 Foam::labelRanges::const_iterator::
86 operator==
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 
99 inline constexpr bool
100 Foam::labelRanges::const_iterator::
101 operator!=
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 
120 Foam::labelRanges::cend() const noexcept
121 {
122  return const_iterator(this, this->size());
123 }
124 
125 
127 Foam::labelRanges::begin() const noexcept
128 {
129  return const_iterator(this);
130 }
131 
132 
134 Foam::labelRanges::end() const noexcept
135 {
136  return const_iterator(this, this->size());
137 }
138 
139 
140 inline 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 // ************************************************************************* //
Foam::labelRanges::found
bool found(const label value) const
Return true if the value is found any of the sub-ranges.
Definition: labelRangesI.H:140
Foam::labelRanges::labelRanges
labelRanges()=default
Default construct.
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::labelRanges::const_iterator::operator++
const_iterator & operator++()
Definition: labelRangesI.H:61
Foam::labelRanges::cend
const const_iterator cend() const noexcept
A const_iterator set to beyond the end of the list.
Definition: labelRangesI.H:120
Foam::labelRanges::begin
const_iterator begin() const noexcept
A const_iterator set to the beginning of the list.
Definition: labelRangesI.H:127
Foam::labelRanges::const_iterator::const_iterator
constexpr const_iterator(const labelRanges *list, const label i=0) noexcept
Construct from range list at given index.
Definition: labelRangesI.H:41
Foam::labelRanges::const_iterator
Forward input iterator with const access.
Definition: labelRanges.H:117
Foam::labelRanges::const_iterator::operator*
label operator*() const
Return the current label.
Definition: labelRangesI.H:53
Foam::labelRanges
A list of labelRange.
Definition: labelRanges.H:59
Foam::labelRange
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:55
Foam::labelRanges::cbegin
const_iterator cbegin() const noexcept
A const_iterator set to the beginning of the list.
Definition: labelRangesI.H:113
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::labelRanges::end
const const_iterator end() const noexcept
A const_iterator set to beyond the end of the list.
Definition: labelRangesI.H:134