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 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 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 :
35 {}
36 
37 
39 :
40  StorageContainer(nElem)
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
45 
46 inline Foam::labelRanges::const_iterator::const_iterator
47 (
48  const labelRanges* lst,
49  const label i
50 )
51 :
52  list_(lst),
53  index_(i < 0 ? lst->size() : i),
54  subIndex_(0)
55 {}
56 
57 
58 inline bool Foam::labelRanges::const_iterator::operator==
59 (
60  const const_iterator& iter
61 ) const
62 {
63  return
64  (
65  this->index_ == iter.index_
66  && this->subIndex_ == iter.subIndex_
67  );
68 }
69 
70 
71 inline bool Foam::labelRanges::const_iterator::operator!=
72 (
73  const const_iterator& iter
74 ) const
75 {
76  return !(this->operator==(iter));
77 }
78 
79 
81 {
82  return list_->operator[](index_)[subIndex_];
83 }
84 
85 
88 {
89  if (++subIndex_ >= list_->operator[](index_).size())
90  {
91  // Next sub-list
92  ++index_;
93  subIndex_ = 0;
94  }
95 
96  return *this;
97 }
98 
99 
102 {
103  const_iterator old = *this;
104  this->operator++();
105  return old;
106 }
107 
108 
110 {
111  return const_iterator(this, 0);
112 }
113 
114 
116 {
117  return const_iterator(this, -1);
118 }
119 
120 
122 {
123  return const_iterator(this, 0);
124 }
125 
126 
128 {
129  return const_iterator(this, -1);
130 }
131 
132 
133 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
134 
135 inline bool Foam::labelRanges::found(const label value) const
136 {
137  forAll(*this, i)
138  {
139  if (StorageContainer::operator[](i).found(value))
140  {
141  return true;
142  }
143  }
144 
145  return false;
146 }
147 
148 
149 // ************************************************************************* //
Foam::labelRanges::found
bool found(const label value) const
Return true if the value is found any of the sub-ranges.
Definition: labelRangesI.H:135
Foam::DynamicList< labelRange >
Foam::labelRanges::const_iterator::operator++
const_iterator & operator++()
Definition: labelRangesI.H:87
Foam::labelRanges::end
const const_iterator end() const
A const_iterator set to beyond the end of the list.
Definition: labelRangesI.H:127
Foam::labelRanges::labelRanges
labelRanges()
Construct null.
Definition: labelRangesI.H:32
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::labelRanges::const_iterator
An STL const_iterator.
Definition: labelRanges.H:117
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:62
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::labelRanges
A list of labelRange.
Definition: labelRanges.H:61
Foam::labelRanges::begin
const_iterator begin() const
A const_iterator set to the beginning of the list.
Definition: labelRangesI.H:121
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::labelRanges::cbegin
const_iterator cbegin() const
A const_iterator set to the beginning of the list.
Definition: labelRangesI.H:109
Foam::labelRanges::const_iterator::operator*
label operator*()
Return the current label.
Definition: labelRangesI.H:80
Foam::labelRanges::cend
const const_iterator cend() const
A const_iterator set to beyond the end of the list.
Definition: labelRangesI.H:115