MOAB: Mesh Oriented datABase  (version 5.2.1)
moab::Range::const_iterator Class Reference

a const iterator which iterates over an Range More...

#include <Range.hpp>

+ Inheritance diagram for moab::Range::const_iterator:
+ Collaboration diagram for moab::Range::const_iterator:

Public Member Functions

 const_iterator ()
 default constructor - intialize base default constructor
 const_iterator (const PairNode *iter, const EntityHandle val)
 constructor used by Range
const EntityHandleoperator* () const
const_iteratoroperator++ ()
 prefix incrementer
const_iterator operator++ (int)
 postfix incrementer
const_iteratoroperator-- ()
 prefix decrementer
const_iterator operator-- (int)
 postfix decrementer
const_iteratoroperator+= (EntityID step)
const_iteratoroperator-= (EntityID step)
bool operator== (const const_iterator &other) const
 equals operator
bool operator!= (const const_iterator &other) const
 not equals operator
const_iterator end_of_block () const
 get an iterator at the end of the block
const_iterator start_of_block () const
 get an iterator at the start of the block

Protected Attributes

PairNodemNode
 the node we are pointing at
EntityHandle mValue
 the value in the range

Friends

class Range
class pair_iterator
class const_pair_iterator
EntityID operator- (const const_iterator &, const const_iterator &)

Detailed Description


Constructor & Destructor Documentation

default constructor - intialize base default constructor

Definition at line 468 of file Range.hpp.

Referenced by end_of_block().

: mNode( NULL ), mValue( 0 ) {}
moab::Range::const_iterator::const_iterator ( const PairNode iter,
const EntityHandle  val 
) [inline]

constructor used by Range

Definition at line 471 of file Range.hpp.

            : mNode( const_cast< PairNode* >( iter ) ), mValue( val )
        {
        }

Member Function Documentation

get an iterator at the end of the block

Get an iterator at the end of the block of consecutive handles that this iterator is currently contained in. That is, if the range contains blocks of consecutive handles of the form { [1,5], [7,100], ... } and this iterator is at any handle in the range [7,100], return an iterator at the '100' handle.

Never returns begin() or end() unless this iterator is at begin() or end(). May return the same location as this iterator.

Definition at line 896 of file Range.hpp.

References const_iterator(), and mNode.

Referenced by moab::Core::adjacencies_iterate(), moab::Core::connect_iterate(), moab::Core::coords_iterate(), moab::BitTag::get_entities_with_bits(), moab::BitTag::get_tagged(), moab::ReadHDF5Dataset::next_end(), moab::ReadHDF5Dataset::read(), and moab::DenseTag::tag_iterate().

{
    return Range::const_iterator( mNode, mNode->second );
}
bool moab::Range::const_iterator::operator!= ( const const_iterator other) const [inline]

not equals operator

Definition at line 555 of file Range.hpp.

References mNode, and mValue.

        {
            // call == operator and not it.
            return ( mNode != other.mNode ) || ( mValue != other.mValue );
        }
const EntityHandle& moab::Range::const_iterator::operator* ( ) const [inline]

dereference that value this iterator points to returns a const reference

Definition at line 478 of file Range.hpp.

        {
            return mValue;
        }
const_iterator& moab::Range::const_iterator::operator++ ( ) [inline]

prefix incrementer

Definition at line 484 of file Range.hpp.

        {
            // see if we need to increment the base iterator
            if( mValue == mNode->second )
            {
                mNode  = mNode->mNext;
                mValue = mNode->first;
            }
            // if not, just increment the value in the range
            else
                ++mValue;
            return *this;
        }
const_iterator moab::Range::const_iterator::operator++ ( int  ) [inline]

postfix incrementer

Definition at line 499 of file Range.hpp.

References moab::operator++().

        {
            // make a temporary copy
            const_iterator tmp( *this );
            // increment self
            this->operator++();
            // return the copy
            return tmp;
        }
Range::const_iterator & moab::Range::const_iterator::operator+= ( EntityID  sstep)

Advance iterator specified amount. Potentially O(n), but typically better. Always more efficient than calling operator++ step times.

advance iterator

Definition at line 88 of file Range.cpp.

References moab::Range::PairNode::mNext, mNode, mValue, and operator-=().

{
    // Check negative now to avoid infinite loop below.
    if( sstep < 0 ) { return operator-=( -sstep ); }
    EntityHandle step = sstep;

    // Handle current PairNode.  Either step is within the current
    // node or need to remove the remainder of the current node
    // from step.
    EntityHandle this_node_rem = mNode->second - mValue;
    if( this_node_rem >= step )
    {
        mValue += step;
        return *this;
    }
    step -= this_node_rem + 1;

    // For each node we are stepping past, decrement step
    // by the size of the node.
    PairNode* node         = mNode->mNext;
    EntityHandle node_size = node->second - node->first + 1;
    while( step >= node_size )
    {
        step -= node_size;
        node      = node->mNext;
        node_size = node->second - node->first + 1;
    }

    // Advance into the resulting node by whatever is
    // left in step.
    mNode  = node;
    mValue = mNode->first + step;
    return *this;
}
const_iterator& moab::Range::const_iterator::operator-- ( ) [inline]

prefix decrementer

Definition at line 510 of file Range.hpp.

        {
            // see if we need to decrement the base iterator
            if( mValue == mNode->first )
            {
                mNode = mNode->mPrev;
                ;
                mValue = mNode->second;
            }
            // if not, just decrement the value
            else
                --mValue;
            return *this;
        }
const_iterator moab::Range::const_iterator::operator-- ( int  ) [inline]

postfix decrementer

Definition at line 526 of file Range.hpp.

        {
            // make a copy of this
            const_iterator tmp( *this );
            // decrement self
            this->operator--();
            // return the copy
            return tmp;
        }
Range::const_iterator & moab::Range::const_iterator::operator-= ( EntityID  sstep)

Regress iterator specified amount. Potentially O(n), but typically better. Always more efficient than calling operator-- step times.

regress iterator

Definition at line 126 of file Range.cpp.

References moab::Range::PairNode::mPrev.

Referenced by operator+=().

{
    // Check negative now to avoid infinite loop below.
    if( sstep < 0 ) { return operator+=( -sstep ); }
    EntityHandle step = sstep;

    // Handle current PairNode.  Either step is within the current
    // node or need to remove the remainder of the current node
    // from step.
    EntityHandle this_node_rem = mValue - mNode->first;
    if( this_node_rem >= step )
    {
        mValue -= step;
        return *this;
    }
    step -= this_node_rem + 1;

    // For each node we are stepping past, decrement step
    // by the size of the node.
    PairNode* node         = mNode->mPrev;
    EntityHandle node_size = node->second - node->first + 1;
    while( step >= node_size )
    {
        step -= node_size;
        node      = node->mPrev;
        node_size = node->second - node->first + 1;
    }

    // Advance into the resulting node by whatever is
    // left in step.
    mNode  = node;
    mValue = mNode->second - step;
    return *this;
}
bool moab::Range::const_iterator::operator== ( const const_iterator other) const [inline]

equals operator

Definition at line 547 of file Range.hpp.

References mNode, and mValue.

        {
            // see if the base iterator is the same and the
            // value of this iterator is the same
            return ( mNode == other.mNode ) && ( mValue == other.mValue );
        }

get an iterator at the start of the block

Get an iterator at the start of the block of consecutive handles that this iterator is currently contained in. That is, if the range contains blocks of consecutive handles of the form { [1,5], [7,100], ... } and this iterator is at any handle in the range [7,100], return an iterator at the '7' handle.

Never returns end() unless this iterator is at end(). May return the same location as this iterator.

Definition at line 901 of file Range.hpp.

Referenced by moab::ReadHDF5VarLen::read_offsets().

{
    return Range::const_iterator( mNode, mNode->first );
}

Friends And Related Function Documentation

friend class const_pair_iterator [friend]

Definition at line 463 of file Range.hpp.

EntityID operator- ( const const_iterator it1,
const const_iterator it2 
) [friend]
friend class pair_iterator [friend]

Definition at line 462 of file Range.hpp.

friend class Range [friend]

Definition at line 461 of file Range.hpp.


Member Data Documentation

the value in the range

Definition at line 595 of file Range.hpp.

Referenced by moab::Range::erase(), operator!=(), operator+=(), moab::operator-(), and operator==().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines