Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
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 More...
 
 const_iterator (const PairNode *iter, const EntityHandle val)
 constructor used by Range More...
 
const EntityHandleoperator* () const
 dereference that value this iterator points to returns a const reference More...
 
const_iteratoroperator++ ()
 prefix incrementer More...
 
const_iterator operator++ (int)
 postfix incrementer More...
 
const_iteratoroperator-- ()
 prefix decrementer More...
 
const_iterator operator-- (int)
 postfix decrementer More...
 
const_iteratoroperator+= (EntityID step)
 Advance iterator specified amount. Potentially O(n), but typically better. Always more efficient than calling operator++ step times. More...
 
const_iteratoroperator-= (EntityID step)
 Regress iterator specified amount. Potentially O(n), but typically better. Always more efficient than calling operator-- step times. More...
 
bool operator== (const const_iterator &other) const
 equals operator More...
 
bool operator!= (const const_iterator &other) const
 not equals operator More...
 
const_iterator end_of_block () const
 get an iterator at the end of the block More...
 
const_iterator start_of_block () const
 get an iterator at the start of the block More...
 

Protected Attributes

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

Friends

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

Additional Inherited Members

- Public Types inherited from moab::range_base_iter
typedef range_iter_tag iterator_category
 
typedef EntityID difference_type
 
typedef EntityHandle value_type
 
typedef EntityHandlepointer
 
typedef EntityHandlereference
 

Detailed Description

a const iterator which iterates over an Range

Examples
ComputeTriDual.cpp.

Definition at line 459 of file Range.hpp.

Constructor & Destructor Documentation

◆ const_iterator() [1/2]

moab::Range::const_iterator::const_iterator ( )
inline

default constructor - intialize base default constructor

Definition at line 468 of file Range.hpp.

468 : mNode( NULL ), mValue( 0 ) {}

◆ const_iterator() [2/2]

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.

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

Member Function Documentation

◆ end_of_block()

Range::const_iterator moab::Range::const_iterator::end_of_block ( ) const
inline

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.

897 {
898  return Range::const_iterator( mNode, mNode->second );
899 }

References 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().

◆ operator!=()

bool moab::Range::const_iterator::operator!= ( const const_iterator other) const
inline

not equals operator

Definition at line 555 of file Range.hpp.

556  {
557  // call == operator and not it.
558  return ( mNode != other.mNode ) || ( mValue != other.mValue );
559  }

References mNode, and mValue.

◆ operator*()

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.

479  {
480  return mValue;
481  }

◆ operator++() [1/2]

const_iterator& moab::Range::const_iterator::operator++ ( )
inline

prefix incrementer

Definition at line 484 of file Range.hpp.

485  {
486  // see if we need to increment the base iterator
487  if( mValue == mNode->second )
488  {
489  mNode = mNode->mNext;
490  mValue = mNode->first;
491  }
492  // if not, just increment the value in the range
493  else
494  ++mValue;
495  return *this;
496  }

◆ operator++() [2/2]

const_iterator moab::Range::const_iterator::operator++ ( int  )
inline

postfix incrementer

Definition at line 499 of file Range.hpp.

500  {
501  // make a temporary copy
502  const_iterator tmp( *this );
503  // increment self
504  this->operator++();
505  // return the copy
506  return tmp;
507  }

References moab::operator++().

◆ operator+=()

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 92 of file Range.cpp.

93 {
94  // Check negative now to avoid infinite loop below.
95  if( sstep < 0 )
96  {
97  return operator-=( -sstep );
98  }
99  EntityHandle step = sstep;
100 
101  // Handle current PairNode. Either step is within the current
102  // node or need to remove the remainder of the current node
103  // from step.
104  EntityHandle this_node_rem = mNode->second - mValue;
105  if( this_node_rem >= step )
106  {
107  mValue += step;
108  return *this;
109  }
110  step -= this_node_rem + 1;
111 
112  // For each node we are stepping past, decrement step
113  // by the size of the node.
114  PairNode* node = mNode->mNext;
115  EntityHandle node_size = node->second - node->first + 1;
116  while( step >= node_size )
117  {
118  step -= node_size;
119  node = node->mNext;
120  node_size = node->second - node->first + 1;
121  }
122 
123  // Advance into the resulting node by whatever is
124  // left in step.
125  mNode = node;
126  mValue = mNode->first + step;
127  return *this;
128 }

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

◆ operator--() [1/2]

const_iterator& moab::Range::const_iterator::operator-- ( )
inline

prefix decrementer

Definition at line 510 of file Range.hpp.

511  {
512  // see if we need to decrement the base iterator
513  if( mValue == mNode->first )
514  {
515  mNode = mNode->mPrev;
516  ;
517  mValue = mNode->second;
518  }
519  // if not, just decrement the value
520  else
521  --mValue;
522  return *this;
523  }

◆ operator--() [2/2]

const_iterator moab::Range::const_iterator::operator-- ( int  )
inline

postfix decrementer

Definition at line 526 of file Range.hpp.

527  {
528  // make a copy of this
529  const_iterator tmp( *this );
530  // decrement self
531  this->operator--();
532  // return the copy
533  return tmp;
534  }

◆ operator-=()

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 133 of file Range.cpp.

134 {
135  // Check negative now to avoid infinite loop below.
136  if( sstep < 0 )
137  {
138  return operator+=( -sstep );
139  }
140  EntityHandle step = sstep;
141 
142  // Handle current PairNode. Either step is within the current
143  // node or need to remove the remainder of the current node
144  // from step.
145  EntityHandle this_node_rem = mValue - mNode->first;
146  if( this_node_rem >= step )
147  {
148  mValue -= step;
149  return *this;
150  }
151  step -= this_node_rem + 1;
152 
153  // For each node we are stepping past, decrement step
154  // by the size of the node.
155  PairNode* node = mNode->mPrev;
156  EntityHandle node_size = node->second - node->first + 1;
157  while( step >= node_size )
158  {
159  step -= node_size;
160  node = node->mPrev;
161  node_size = node->second - node->first + 1;
162  }
163 
164  // Advance into the resulting node by whatever is
165  // left in step.
166  mNode = node;
167  mValue = mNode->second - step;
168  return *this;
169 }

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

Referenced by operator+=().

◆ operator==()

bool moab::Range::const_iterator::operator== ( const const_iterator other) const
inline

equals operator

Definition at line 547 of file Range.hpp.

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

References mNode, and mValue.

◆ start_of_block()

Range::const_iterator moab::Range::const_iterator::start_of_block ( ) const
inline

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.

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

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

Friends And Related Function Documentation

◆ const_pair_iterator

friend class const_pair_iterator
friend

Definition at line 463 of file Range.hpp.

◆ operator-

EntityID operator- ( const const_iterator it1,
const const_iterator it2 
)
friend

Definition at line 793 of file Range.cpp.

794 {
795  assert( !it2.mValue || *it2 >= *it1 );
796  if( it2.mNode == it1.mNode )
797  {
798  return *it2 - *it1;
799  }
800 
801  EntityID result = it1.mNode->second - it1.mValue + 1;
802  for( Range::PairNode* n = it1.mNode->mNext; n != it2.mNode; n = n->mNext )
803  result += n->second - n->first + 1;
804  if( it2.mValue ) // (it2.mNode != &mHead)
805  result += it2.mValue - it2.mNode->first;
806  return result;
807 }

◆ pair_iterator

friend class pair_iterator
friend

Definition at line 462 of file Range.hpp.

◆ Range

friend class Range
friend

Definition at line 461 of file Range.hpp.

Member Data Documentation

◆ mNode

PairNode* moab::Range::const_iterator::mNode
protected

the node we are pointing at

Definition at line 593 of file Range.hpp.

Referenced by end_of_block(), moab::Range::erase(), moab::Range::insert(), moab::Range::lower_bound(), operator!=(), operator+=(), and operator==().

◆ mValue

EntityHandle moab::Range::const_iterator::mValue
protected

the value in the range

Definition at line 595 of file Range.hpp.

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


The documentation for this class was generated from the following files: