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 | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 
27 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
28 
30 :
31  ParentType()
32 {}
33 
34 
36 :
37  ParentType(nElem)
38 {}
39 
40 
41 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
42 
44 :
45  list_(*reinterpret_cast< Foam::labelRanges* >(0)),
46  index_(-1),
47  subIndex_(-1)
48 {}
49 
50 
52 :
53  list_(lst),
54  index_(0),
55  subIndex_(0)
56 {
57  if (list_.empty())
58  {
59  // equivalent to end iterator
60  index_ = subIndex_ = -1;
61  }
62 }
63 
64 
65 inline bool Foam::labelRanges::const_iterator::operator==
66 (
67  const const_iterator& iter
68 ) const
69 {
70  return
71  (
72  this->index_ == iter.index_
73  && this->subIndex_ == iter.subIndex_
74  );
75 }
76 
77 
78 inline bool Foam::labelRanges::const_iterator::operator!=
79 (
80  const const_iterator& iter
81 ) const
82 {
83  return !(this->operator==(iter));
84 }
85 
86 
88 {
89  return list_[index_][subIndex_];
90 }
91 
92 
94 {
95  return list_[index_][subIndex_];
96 }
97 
98 
101 {
102  if (++subIndex_ >= list_[index_].size())
103  {
104  // go to next list entry
105  subIndex_ = 0;
106  if (++index_ >= list_.size())
107  {
108  // equivalent to end iterator
109  index_ = subIndex_ = -1;
110  }
111  }
112 
113  return *this;
114 }
115 
116 
119 {
120  const_iterator old = *this;
121  this->operator++();
122  return old;
123 }
124 
125 
127 {
128  return const_iterator(*this);
129 }
130 
131 
133 {
134  return endIter_;
135 }
136 
137 
139 {
140  return const_iterator(*this);
141 }
142 
143 
145 {
146  return endIter_;
147 }
148 
149 
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 
152 inline bool Foam::labelRanges::contains(const label value) const
153 {
154  forAll(*this, i)
155  {
156  if (this->ParentType::operator[](i).contains(value))
157  {
158  return true;
159  }
160  }
161 
162  return false;
163 }
164 
165 
166 // ************************************************************************* //
reinterpret_cast
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::endConstIter * reinterpret_cast(0), -1, false, -1, false
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::DynamicList< labelRange >
Foam::labelRanges::const_iterator::operator++
const_iterator & operator++()
Definition: labelRangesI.H:100
Foam::labelRanges::labelRanges
labelRanges()
Construct null.
Definition: labelRangesI.H:29
Foam::labelRanges::end
const const_iterator & end() const
const_iterator set to beyond the end of the list
Definition: labelRangesI.H:144
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::labelRanges::const_iterator
An STL const_iterator.
Definition: labelRanges.H:113
Foam::labelRanges::const_iterator::subIndex_
label subIndex_
Index of current element at listIndex.
Definition: labelRanges.H:124
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::labelRanges
A list of labelRange.
Definition: labelRanges.H:58
Foam::labelRanges::const_iterator::const_iterator
const_iterator()
Construct null - equivalent to an 'end' position.
Definition: labelRangesI.H:43
Foam::labelRanges::const_iterator::list_
const labelRanges & list_
Reference to the list for which this is an iterator.
Definition: labelRanges.H:118
Foam::labelRanges::begin
const_iterator begin() const
const_iterator set to the beginning of the list
Definition: labelRangesI.H:138
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::labelRanges::cend
const const_iterator & cend() const
const_iterator set to beyond the end of the list
Definition: labelRangesI.H:132
Foam::labelRanges::cbegin
const_iterator cbegin() const
const_iterator set to the beginning of the list
Definition: labelRangesI.H:126
Foam::labelRanges::contains
bool contains(const label) const
Return true if the value is within any of the ranges.
Definition: labelRangesI.H:152
Foam::labelRanges::const_iterator::operator*
label operator*()
Definition: labelRangesI.H:87
Foam::labelRanges::endIter_
static const const_iterator endIter_
const_iterator returned by end(), cend()
Definition: labelRanges.H:173
Foam::labelRanges::const_iterator::operator()
label operator()()
Definition: labelRangesI.H:93
Foam::DynamicList< labelRange >::operator
friend Ostream & operator(Ostream &, const DynamicList< T, SizeInc, SizeMult, SizeDiv > &)
Foam::labelRanges::const_iterator::index_
label index_
Current list index.
Definition: labelRanges.H:121