moab
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:
moab::range_base_iter

List of all members.

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

a const iterator which iterates over an Range

Examples:
DeformMeshRemap.cpp, DirectAccessNoHoles.cpp, DirectAccessWithHoles.cpp, GetEntities.cpp, LloydRelaxation.cpp, SetsNTags.cpp, and TestExodusII.cpp.

Definition at line 442 of file Range.hpp.


Constructor & Destructor Documentation

default constructor - intialize base default constructor

Definition at line 450 of file Range.hpp.

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

constructor used by Range

Definition at line 453 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 816 of file Range.hpp.

  { 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 531 of file Range.hpp.

    {
      // 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 458 of file Range.hpp.

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

prefix incrementer

Definition at line 461 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 476 of file Range.hpp.

    {
      // 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 77 of file Range.cpp.

{
    // 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 487 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 502 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 120 of file Range.cpp.

{
    // 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 523 of file Range.hpp.

    {
      // 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 819 of file Range.hpp.

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

Friends And Related Function Documentation

friend class const_pair_iterator [friend]

Definition at line 446 of file Range.hpp.

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

Definition at line 445 of file Range.hpp.

friend class Range [friend]

Definition at line 444 of file Range.hpp.


Member Data Documentation

the node we are pointing at

Definition at line 570 of file Range.hpp.

the value in the range

Definition at line 572 of file Range.hpp.


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