1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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::labelRange::labelRange()
36 inline Foam::labelRange::labelRange(const label start, const label size)
41 // disallow invalid sizes
49 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
51 inline Foam::labelRange::const_iterator::const_iterator()
53 range_(*reinterpret_cast< Foam::labelRange* >(0)),
58 inline Foam::labelRange::const_iterator::const_iterator(const labelRange& range)
61 index_(range_.empty() ? -1 : 0)
65 inline bool Foam::labelRange::const_iterator::operator==
67 const const_iterator& iter
70 return (this->index_ == iter.index_);
74 inline bool Foam::labelRange::const_iterator::operator!=
76 const const_iterator& iter
79 return !(this->operator==(iter));
83 inline Foam::label Foam::labelRange::const_iterator::operator*()
85 return range_[index_];
89 inline Foam::label Foam::labelRange::const_iterator::operator()()
91 return range_[index_];
95 inline Foam::labelRange::const_iterator&
96 Foam::labelRange::const_iterator::operator++()
98 if (++index_ >= range_.size())
100 // equivalent to end iterator
108 inline Foam::labelRange::const_iterator
109 Foam::labelRange::const_iterator::operator++(int)
111 const_iterator old = *this;
117 inline Foam::labelRange::const_iterator Foam::labelRange::cbegin() const
119 return const_iterator(*this);
123 inline const Foam::labelRange::const_iterator& Foam::labelRange::cend() const
129 inline Foam::labelRange::const_iterator Foam::labelRange::begin() const
131 return const_iterator(*this);
135 inline const Foam::labelRange::const_iterator& Foam::labelRange::end() const
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 inline void Foam::labelRange::clear()
149 inline bool Foam::labelRange::empty() const
155 inline Foam::label Foam::labelRange::size() const
161 inline Foam::label Foam::labelRange::first() const
167 inline Foam::label Foam::labelRange::last() const
169 return start_ + size_ - 1;
173 inline bool Foam::labelRange::contains(const label value) const
175 return value >= this->first() && value <= this->last();
179 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
181 inline Foam::label Foam::labelRange::operator[](const label i) const
187 inline bool Foam::labelRange::operator<(const labelRange& rhs) const
189 return this->first() < rhs.first();
193 inline bool Foam::labelRange::operator==(const labelRange& rhs) const
195 return start_ == rhs.start_ && size_ == rhs.size_;
199 inline bool Foam::labelRange::operator!=(const labelRange& rhs) const
201 return !(operator==(rhs));
205 // ************************************************************************* //