ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / primitives / ranges / labelRange / labelRangesI.H
blob2c6f75aeccc155cbc9740d63cc28d6439eab9796
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.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
29 inline Foam::labelRanges::labelRanges()
31     ParentType()
35 inline Foam::labelRanges::labelRanges(const label nElem)
37     ParentType(nElem)
41 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
43 inline Foam::labelRanges::const_iterator::const_iterator()
45    list_(*reinterpret_cast< Foam::labelRanges* >(0)),
46    index_(-1),
47    subIndex_(-1)
51 inline Foam::labelRanges::const_iterator::const_iterator(const labelRanges& lst)
53    list_(lst),
54    index_(0),
55    subIndex_(0)
57     if (list_.empty())
58     {
59         // equivalent to end iterator
60         index_ = subIndex_ = -1;
61     }
65 inline bool Foam::labelRanges::const_iterator::operator==
67     const const_iterator& iter
68 ) const
70     return
71     (
72         this->index_ == iter.index_
73      && this->subIndex_ == iter.subIndex_
74     );
78 inline bool Foam::labelRanges::const_iterator::operator!=
80     const const_iterator& iter
81 ) const
83     return !(this->operator==(iter));
87 inline Foam::label Foam::labelRanges::const_iterator::operator*()
89     return list_[index_][subIndex_];
93 inline Foam::label Foam::labelRanges::const_iterator::operator()()
95     return list_[index_][subIndex_];
99 inline Foam::labelRanges::const_iterator&
100 Foam::labelRanges::const_iterator::operator++()
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     }
113     return *this;
117 inline Foam::labelRanges::const_iterator
118 Foam::labelRanges::const_iterator::operator++(int)
120     const_iterator old = *this;
121     this->operator++();
122     return old;
126 inline Foam::labelRanges::const_iterator Foam::labelRanges::cbegin() const
128     return const_iterator(*this);
132 inline const Foam::labelRanges::const_iterator& Foam::labelRanges::cend() const
134     return endIter_;
138 inline Foam::labelRanges::const_iterator Foam::labelRanges::begin() const
140     return const_iterator(*this);
144 inline const Foam::labelRanges::const_iterator& Foam::labelRanges::end() const
146     return endIter_;
150 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
152 inline bool Foam::labelRanges::contains(const label value) const
154     forAll(*this, i)
155     {
156         if (this->ParentType::operator[](i).contains(value))
157         {
158             return true;
159         }
160     }
162     return false;
166 // ************************************************************************* //