/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::Circulator::Circulator() : CirculatorBase(), begin_(0), end_(0), iter_(0), fulcrum_(0) {} template Foam::Circulator::Circulator(ContainerType& container) : CirculatorBase(), begin_(container.begin()), end_(container.end()), iter_(begin_), fulcrum_(begin_) {} template Foam::Circulator::Circulator ( const iterator& begin, const iterator& end ) : CirculatorBase(), begin_(begin), end_(end), iter_(begin), fulcrum_(begin) {} template Foam::Circulator::Circulator ( const Circulator& rhs ) : CirculatorBase(), begin_(rhs.begin_), end_(rhs.end_), iter_(rhs.iter_), fulcrum_(rhs.fulcrum_) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template Foam::Circulator::~Circulator() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template typename Foam::Circulator::size_type Foam::Circulator::size() const { return end_ - begin_; } template bool Foam::Circulator::circulate ( const CirculatorBase::direction dir ) { if (dir == CirculatorBase::CLOCKWISE) { operator++(); } else if (dir == CirculatorBase::ANTICLOCKWISE) { operator--(); } return !(iter_ == fulcrum_); } template void Foam::Circulator::setFulcrumToIterator() { fulcrum_ = iter_; } template void Foam::Circulator::setIteratorToFulcrum() { iter_ = fulcrum_; } template typename Foam::Circulator::difference_type Foam::Circulator::nRotations() const { return (iter_ - fulcrum_); } template typename Foam::Circulator::reference Foam::Circulator::next() const { if (iter_ == end_ - 1) { return *begin_; } return *(iter_ + 1); } template typename Foam::Circulator::reference Foam::Circulator::prev() const { if (iter_ == begin_) { return *(end_ - 1); } return *(iter_ - 1); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template void Foam::Circulator::operator= ( const Circulator& rhs ) { if (this == &rhs) { return; // Self-assignment is a no-op } begin_ = rhs.begin_; end_ = rhs.end_; iter_ = rhs.iter_; fulcrum_ = rhs.fulcrum_; } template Foam::Circulator& Foam::Circulator::operator++() { ++iter_; if (iter_ == end_) { iter_ = begin_; } return *this; } template Foam::Circulator Foam::Circulator::operator++(int) { Circulator tmp = *this; ++(*this); return tmp; } template Foam::Circulator& Foam::Circulator::operator--() { if (iter_ == begin_) { iter_ = end_; } --iter_; return *this; } template Foam::Circulator Foam::Circulator::operator--(int) { Circulator tmp = *this; --(*this); return tmp; } template bool Foam::Circulator::operator== ( const Circulator& c ) const { return ( begin_ == c.begin_ && end_ == c.end_ && iter_ == c.iter_ && fulcrum_ == c.fulcrum_ ); } template bool Foam::Circulator::operator!= ( const Circulator& c ) const { return !(*this == c); } template typename Foam::Circulator::reference Foam::Circulator::operator*() const { return *iter_; } template typename Foam::Circulator::reference Foam::Circulator::operator()() const { return operator*(); } template typename Foam::Circulator::difference_type Foam::Circulator::operator- ( const Circulator& c ) const { return iter_ - c.iter_; } // ************************************************************************* //