moab
|
#include <Range.hpp>
Classes | |
class | const_iterator |
a const iterator which iterates over an Range More... | |
class | const_pair_iterator |
class | const_reverse_iterator |
a const reverse iterator which iterates over an Range More... | |
class | pair_iterator |
used to iterate over sub-ranges of a range More... | |
struct | PairNode |
Public Types | |
typedef const_iterator | iterator |
typedef const_reverse_iterator | reverse_iterator |
typedef EntityHandle | value_type |
Public Member Functions | |
Range & | operator-= (const Range &rhs) |
just like subtract, but as an operator | |
Range () | |
default constructor | |
Range (const Range ©) | |
copy constructor | |
Range (EntityHandle val1, EntityHandle val2) | |
another constructor that takes an initial range | |
Range & | operator= (const Range ©) |
operator= | |
~Range () | |
destructor | |
const_iterator | begin () const |
return the beginning const iterator of this range | |
const_reverse_iterator | rbegin () const |
return the beginning const reverse iterator of this range | |
const_iterator | end () const |
return the ending const iterator for this range | |
const_reverse_iterator | rend () const |
return the ending const reverse iterator for this range | |
size_t | size () const |
return the number of values this Ranges represents | |
size_t | psize () const |
return the number of range pairs in the list | |
bool | empty () const |
iterator | insert (iterator hint, EntityHandle val) |
iterator | insert (EntityHandle val) |
insert an item into the list and return the iterator for the inserted item | |
iterator | insert (iterator hint, EntityHandle first, EntityHandle last) |
iterator | insert (EntityHandle val1, EntityHandle val2) |
template<typename T > | |
iterator | insert_list (T begin_iter, T end_iter) |
template<class T > | |
iterator | insert (typename T::const_iterator begin_iter, typename T::const_iterator end_iter) |
template<typename T > | |
iterator | insert (const T *begin_iter, const T *end_iter) |
iterator | erase (iterator iter) |
remove an item from this list and return an iterator to the next item | |
iterator | erase (iterator iter1, iterator iter2) |
remove a range of items from the list | |
iterator | erase (EntityHandle val) |
erases a value from this container | |
const EntityHandle & | front () const |
get first entity in range | |
const EntityHandle & | back () const |
get last entity in range | |
EntityHandle | pop_front () |
remove first entity from range | |
EntityHandle | pop_back () |
remove last entity from range | |
const_iterator | find (EntityHandle val) const |
find an item int the list and return an iterator at that value | |
const_iterator | lower_bound (EntityHandle val) const |
const_iterator | upper_bound (EntityHandle val) const |
const_iterator | lower_bound (EntityType type) const |
const_iterator | upper_bound (EntityType type) const |
std::pair< const_iterator, const_iterator > | equal_range (EntityType type) const |
const_iterator | lower_bound (EntityType type, const_iterator first) const |
const_iterator | upper_bound (EntityType type, const_iterator first) const |
bool | all_of_type (EntityType type) const |
bool | all_of_dimension (int dimension) const |
unsigned | num_of_type (EntityType type) const |
unsigned | num_of_dimension (int dim) const |
void | clear () |
clears the contents of the list | |
void | print (const char *indent_prefix=NULL) const |
for debugging | |
void | print (std::ostream &s, const char *indent_prefix=NULL) const |
unsigned long | get_memory_use () const |
double | compactness () const |
void | insert (Range::const_iterator begin, Range::const_iterator end) |
void | merge (const Range &range) |
merges this Range with another range | |
void | merge (Range::const_iterator beginr, Range::const_iterator endr) |
merge a subset of some other range | |
void | swap (Range &range) |
swap the contents of this range with another one | |
void | sanity_check () const |
check for internal consistency | |
bool | contains (const Range &other) const |
Check if this range is a non-strict superset of some other range. | |
Range | subset_by_type (EntityType t) const |
return a subset of this range, by type | |
Range | subset_by_dimension (int dim) const |
return a subset of this range, by dimension | |
EntityHandle | operator[] (EntityID index) const |
int | index (EntityHandle handle) const |
pair_iterator | pair_begin () |
pair_iterator | pair_end () |
const_pair_iterator | const_pair_begin () const |
const_pair_iterator | const_pair_end () const |
const_pair_iterator | pair_begin () const |
const_pair_iterator | pair_end () const |
template<typename Iterator > | |
Range::iterator | insert_list (Iterator begin_iter, Iterator end_iter) |
Static Public Member Functions | |
static const_iterator | lower_bound (const_iterator first, const_iterator last, EntityHandle val) |
return an iterator to the first value >= val | |
static const_iterator | upper_bound (const_iterator first, const_iterator last, EntityHandle val) |
Protected Member Functions | |
void | delete_pair_node (PairNode *dead_node) |
if dead_node is not mHead, remove it from the list and free it's memory. | |
Protected Attributes | |
PairNode | mHead |
Friends | |
Range | intersect (const Range &, const Range &) |
intersect two ranges, placing the results in the return range | |
Range | subtract (const Range &, const Range &) |
subtract range2 from this, placing the results in the return range |
the class Range
typedef const_iterator moab::Range::iterator |
typedef EntityHandle moab::Range::value_type |
moab::Range::Range | ( | ) | [inline] |
moab::Range::Range | ( | const Range & | copy | ) |
copy constructor
Definition at line 169 of file Range.cpp.
{ // set the head node to point to itself mHead.mNext = mHead.mPrev = &mHead; mHead.first = mHead.second = 0; const PairNode* copy_node = copy.mHead.mNext; PairNode* new_node = &mHead; for(; copy_node != &(copy.mHead); copy_node = copy_node->mNext) { PairNode* tmp_node = alloc_pair(new_node->mNext, new_node, copy_node->first, copy_node->second); new_node->mNext->mPrev = tmp_node; new_node->mNext = tmp_node; new_node = tmp_node; } }
moab::Range::Range | ( | EntityHandle | val1, |
EntityHandle | val2 | ||
) |
moab::Range::~Range | ( | ) | [inline] |
bool moab::Range::all_of_dimension | ( | int | dimension | ) | const |
True if all entities in range are of passed dimension (also true if range is empty)
Definition at line 882 of file Range.cpp.
{ return empty() || (CN::Dimension(TYPE_FROM_HANDLE(front())) == dimension && CN::Dimension(TYPE_FROM_HANDLE(back())) == dimension); }
bool moab::Range::all_of_type | ( | EntityType | type | ) | const |
True if all entities in range are of passed type (also true if range is empty)
Definition at line 875 of file Range.cpp.
{ return empty() || (TYPE_FROM_HANDLE(front()) == type && TYPE_FROM_HANDLE(back()) == type); }
const EntityHandle & moab::Range::back | ( | ) | const [inline] |
Range::const_iterator moab::Range::begin | ( | ) | const [inline] |
return the beginning const iterator of this range
void moab::Range::clear | ( | ) |
clears the contents of the list
double moab::Range::compactness | ( | ) | const [inline] |
Definition at line 858 of file Range.hpp.
{ unsigned int num_ents = size(); return (num_ents ? ((double)get_memory_use() / (double) (num_ents*sizeof(EntityHandle))) : -1); }
const_pair_iterator moab::Range::const_pair_begin | ( | ) | const [inline] |
const_pair_iterator moab::Range::const_pair_end | ( | ) | const [inline] |
bool moab::Range::contains | ( | const Range & | other | ) | const |
Check if this range is a non-strict superset of some other range.
Definition at line 1014 of file Range.cpp.
{ if (othr.empty()) return true; if (empty()) return false; // neither range is empty, so both have valid pair nodes // other than dummy mHead const PairNode* this_node = mHead.mNext; const PairNode* othr_node = othr.mHead.mNext; for(;;) { // Loop while the node in this list is entirely before // the node in the other list. while (this_node->second < othr_node->first) { this_node = this_node->mNext; if (this_node == &mHead) return false; } // If other node is not entirely contained in this node // then other list is not contained in this list if (this_node->first > othr_node->first) break; // Loop while other node is entirely contained in this node. while (othr_node->second <= this_node->second) { othr_node = othr_node->mNext; if (othr_node == &othr.mHead) return true; } // If other node overlapped end of this node if (othr_node->first <= this_node->second) break; } // should be unreachable return false; }
void moab::Range::delete_pair_node | ( | PairNode * | dead_node | ) | [protected] |
bool moab::Range::empty | ( | ) | const [inline] |
return whether empty or not always use "if(!Ranges::empty())" instead of "if(Ranges::size())"
Range::const_iterator moab::Range::end | ( | ) | const [inline] |
return the ending const iterator for this range
std::pair< Range::const_iterator, Range::const_iterator > moab::Range::equal_range | ( | EntityType | type | ) | const |
Definition at line 863 of file Range.cpp.
{ std::pair<Range::const_iterator, Range::const_iterator> result; int err; EntityHandle handle = CREATE_HANDLE( type, 0, err ); result.first = err ? end() : lower_bound( begin(), end(), handle ); // if (type+1) overflows, err will be true and we return end(). handle = CREATE_HANDLE( type+1, 0, err ); result.second = err ? end() : lower_bound( result.first, end(), handle ); return result; }
remove an item from this list and return an iterator to the next item
erases an item from this list and returns an iterator to the next item
Definition at line 369 of file Range.cpp.
{ // one of a few things could happen // 1. shrink a range // 2. split a range // 3. remove a range if(iter == end()) return end(); // the iterator most likely to be returned iterator new_iter = iter; ++new_iter; PairNode* kter = iter.mNode; // just remove the range if(kter->first == kter->second) { kter->mNext->mPrev = kter->mPrev; kter->mPrev->mNext = kter->mNext; free_pair( kter ); return new_iter; } // shrink it else if(kter->first == iter.mValue) { kter->first++; return new_iter; } // shrink it the other way else if(kter->second == iter.mValue) { kter->second--; return new_iter; } // split the range else { PairNode* new_node = alloc_pair(iter.mNode->mNext, iter.mNode, iter.mValue+1, kter->second); new_node->mPrev->mNext = new_node->mNext->mPrev = new_node; iter.mNode->second = iter.mValue - 1; new_iter = const_iterator(new_node, new_node->first); return new_iter; } }
Range::iterator moab::Range::erase | ( | iterator | iter1, |
iterator | iter2 | ||
) |
remove a range of items from the list
Definition at line 419 of file Range.cpp.
{ iterator result; if (iter1.mNode == iter2.mNode) { if (iter2.mValue <= iter1.mValue) { // empty range OK, otherwise invalid input return iter2; } // If both iterators reference the same pair node, then // we're either removing values from the front of the // node or splitting the node. We can never be removing // the last value in the node in this case because iter2 // points *after* the last entry to be removed. PairNode* node = iter1.mNode; if (iter1.mValue == node->first) { node->first = iter2.mValue; result = iter2; } else { PairNode* new_node = alloc_pair( node->mNext, node, iter2.mValue, node->second ); new_node->mNext->mPrev = new_node; new_node->mPrev->mNext = new_node; node->second = iter1.mValue - 1; result = iterator( new_node, new_node->first ); } } else { if (iter1.mNode == &mHead) return iter1; PairNode* dn = iter1.mNode; if (iter1.mValue > dn->first) { dn->second = iter1.mValue-1; dn = dn->mNext; } if (iter2.mNode != &mHead) iter2.mNode->first = iter2.mValue; while (dn != iter2.mNode) { PairNode* dead = dn; dn = dn->mNext; dead->mPrev->mNext = dead->mNext; dead->mNext->mPrev = dead->mPrev; dead->mPrev = dead->mNext = 0; delete dead; } result = iter2; } return result; }
Range::iterator moab::Range::erase | ( | EntityHandle | val | ) | [inline] |
Range::const_iterator moab::Range::find | ( | EntityHandle | val | ) | const |
find an item int the list and return an iterator at that value
finds a value in the list. this method is preferred over other algorithms because it can be found faster this way.
const EntityHandle & moab::Range::front | ( | ) | const [inline] |
unsigned long moab::Range::get_memory_use | ( | ) | const |
int moab::Range::index | ( | EntityHandle | handle | ) | const [inline] |
Definition at line 843 of file Range.hpp.
{ if (handle < *begin() || handle > *rbegin()) return -1; unsigned int i = 0; Range::const_pair_iterator pit = const_pair_begin(); while (handle > (*pit).second && pit != const_pair_end()) { i += (*pit).second - (*pit).first + 1; pit++; } if (handle < (*pit).first || pit == const_pair_end()) return -1; return i + handle - (*pit).first; }
Range::iterator moab::Range::insert | ( | Range::iterator | hint, |
EntityHandle | val | ||
) |
inserts a single value into this range
Definition at line 222 of file Range.cpp.
{ // don't allow zero-valued handles in Range if(val == 0) return end(); // if this is empty, just add it and return an iterator to it if(&mHead == mHead.mNext) { mHead.mNext = mHead.mPrev = alloc_pair(&mHead, &mHead, val, val); return iterator(mHead.mNext, val); } // find the location in the list where we can safely insert // new items and keep it ordered PairNode* hter = hint.mNode; PairNode* jter = hter->first <= val ? hter : mHead.mNext; for( ; (jter != &mHead) && (jter->second < val); jter=jter->mNext); PairNode* iter = jter; jter = jter->mPrev; // if this val is already in the list if( (iter->first <= val && iter->second >= val) && (iter != &mHead) ) { // return an iterator pointing to this location return iterator( iter, val ); } // one of a few things can happen at this point // 1. this range needs to be backwardly extended // 2. the previous range needs to be forwardly extended // 3. a new range needs to be added // extend this range back a bit else if( (iter->first == (val+1)) && (iter != &mHead) ) { iter->first = val; // see if we need to merge two ranges if( (iter != mHead.mNext) && (jter->second == (val-1))) { jter->second = iter->second; iter->mPrev->mNext = iter->mNext; iter->mNext->mPrev = iter->mPrev; free_pair( iter ); return iterator( jter, val ); } else { return iterator( iter, val ); } } // extend the previous range forward a bit else if( (jter->second == (val-1)) && (iter != mHead.mNext) ) { jter->second = val; return iterator(jter, val); } // make a new range else { PairNode* new_node = alloc_pair(iter, iter->mPrev, val, val); iter->mPrev = new_node->mPrev->mNext = new_node; return iterator(new_node, val); } }
iterator moab::Range::insert | ( | EntityHandle | val | ) | [inline] |
Range::iterator moab::Range::insert | ( | Range::iterator | prev, |
EntityHandle | first, | ||
EntityHandle | last | ||
) |
insert a range of items into this list and return the iterator for the first inserted item
Definition at line 291 of file Range.cpp.
{ if(val1 == 0 || val1 > val2) return end(); // Empty if (mHead.mNext == &mHead) { assert( prev == end() ); PairNode* new_node = alloc_pair( &mHead, &mHead, val1, val2 ); mHead.mNext = mHead.mPrev = new_node; return iterator( mHead.mNext, val1 ); } PairNode* iter = prev.mNode; // If iterator is at end, set it to last. // Thus if the hint was to append, we start searching // at the end of the list. if (iter == &mHead) iter = mHead.mPrev; // if hint (prev) is past insert position, reset it to the beginning. if (iter != &mHead && iter->first > val2+1) iter = mHead.mNext; // If hint is bogus then search backwards while (iter != mHead.mNext && iter->mPrev->second >= val1-1) iter = iter->mPrev; // Input range is before beginning? if (iter->mPrev == &mHead && val2 < iter->first - 1) { PairNode* new_node = alloc_pair( iter, &mHead, val1, val2 ); mHead.mNext = iter->mPrev = new_node; return iterator( mHead.mNext, val1 ); } // Find first intersecting list entry, or the next entry // if none intersects. while (iter != &mHead && iter->second+1 < val1) iter = iter->mNext; // Need to insert new pair (don't intersect any existing pair)? if (iter == &mHead || iter->first-1 > val2) { PairNode* new_node = alloc_pair( iter, iter->mPrev, val1, val2 ); iter->mPrev = iter->mPrev->mNext = new_node; return iterator( iter->mPrev, val1 ); } // Make the first intersecting pair the union of itself with [val1,val2] if (iter->first > val1) iter->first = val1; if (iter->second >= val2) return iterator( iter, val1 ); iter->second = val2; // Merge any remaining pairs that intersect [val1,val2] while (iter->mNext != &mHead && iter->mNext->first <= val2 + 1) { PairNode* dead = iter->mNext; iter->mNext = dead->mNext; dead->mNext->mPrev = iter; if (dead->second > val2) iter->second = dead->second; free_pair( dead ); } return iterator( iter, val1 ); }
iterator moab::Range::insert | ( | EntityHandle | val1, |
EntityHandle | val2 | ||
) | [inline] |
iterator moab::Range::insert | ( | typename T::const_iterator | begin_iter, |
typename T::const_iterator | end_iter | ||
) | [inline] |
Definition at line 263 of file Range.hpp.
{ return insert_list( begin_iter, end_iter ); }
iterator moab::Range::insert | ( | const T * | begin_iter, |
const T * | end_iter | ||
) | [inline] |
Definition at line 267 of file Range.hpp.
{ return insert_list( begin_iter, end_iter ); }
void moab::Range::insert | ( | Range::const_iterator | begini, |
Range::const_iterator | endi | ||
) |
merges another Range with this one
Definition at line 524 of file Range.cpp.
{ if (begini == endi) return; PairNode* node = begini.mNode; if (endi.mNode == node) { insert( *begini, (*endi)-1 ); return; } Range::iterator hint = insert( *begini, node->second ); node = node->mNext; while (node != endi.mNode) { hint = insert( hint, node->first, node->second ); node = node->mNext; } if (*endi > node->first) { if (*endi <= node->second) insert( hint, node->first, *(endi) - 1 ); else insert( hint, node->first, node->second ); } }
iterator moab::Range::insert_list | ( | T | begin_iter, |
T | end_iter | ||
) |
Range::iterator moab::Range::insert_list | ( | Iterator | begin_iter, |
Iterator | end_iter | ||
) |
Definition at line 865 of file Range.hpp.
{ size_t n = std::distance(begin_iter, end_iter); EntityHandle* sorted = new EntityHandle[n]; std::copy( begin_iter, end_iter, sorted ); std::sort( sorted, sorted + n ); iterator hint = begin(); size_t i = 0; while (i < n) { size_t j = i + 1; while (j < n && sorted[j] == 1+sorted[j-1]) ++j; hint = insert( hint, sorted[i], sorted[i] + ((j - i) - 1) ); i = j; } delete [] sorted; return hint; }
Range::const_iterator moab::Range::lower_bound | ( | Range::const_iterator | first, |
Range::const_iterator | last, | ||
EntityHandle | val | ||
) | [static] |
return an iterator to the first value >= val
Definition at line 796 of file Range.cpp.
{ // Find the first pair whose end is >= val PairNode* iter; for (iter = first.mNode; iter != last.mNode; iter = iter->mNext) { if (iter->second >= val) { // This is the correct pair. Either 'val' is in the range, or // the range starts before 'val' and iter->first IS the lower_bound. if (iter->first > val) return const_iterator(iter, iter->first); return const_iterator(iter, val); } } if (iter->first >= val) return const_iterator( iter, iter->first ); else if(*last > val) return const_iterator( iter, val ); else return last; }
const_iterator moab::Range::lower_bound | ( | EntityHandle | val | ) | const [inline] |
Definition at line 299 of file Range.hpp.
{ return lower_bound( begin(), end(), val ); }
Range::const_iterator moab::Range::lower_bound | ( | EntityType | type | ) | const |
Definition at line 832 of file Range.cpp.
{ int err; EntityHandle handle = CREATE_HANDLE( type, 0, err ); return err ? end() : lower_bound( begin(), end(), handle ); }
Range::const_iterator moab::Range::lower_bound | ( | EntityType | type, |
const_iterator | first | ||
) | const |
Definition at line 838 of file Range.cpp.
{ int err; EntityHandle handle = CREATE_HANDLE( type, 0, err ); return err ? end() : lower_bound( first, end(), handle ); }
void moab::Range::merge | ( | const Range & | range | ) | [inline] |
merges this Range with another range
Definition at line 334 of file Range.hpp.
{ insert( range.begin(), range.end() ); }
void moab::Range::merge | ( | Range::const_iterator | beginr, |
Range::const_iterator | endr | ||
) | [inline] |
unsigned moab::Range::num_of_dimension | ( | int | dim | ) | const |
Definition at line 911 of file Range.cpp.
{ const_pair_iterator iter = const_pair_begin(); while(iter != const_pair_end() && CN::Dimension(TYPE_FROM_HANDLE((*iter).second)) < dim) ++iter; int junk; unsigned count = 0; for ( ; iter != const_pair_end(); ++iter) { int start_dim = CN::Dimension(TYPE_FROM_HANDLE((*iter).first)); int end_dim = CN::Dimension(TYPE_FROM_HANDLE((*iter).second)); if (start_dim > dim) break; EntityHandle sh = start_dim < dim ? CREATE_HANDLE( CN::TypeDimensionMap[dim].first, 1, junk ) : (*iter).first; EntityHandle eh = end_dim > dim ? CREATE_HANDLE( CN::TypeDimensionMap[dim].second, MB_END_ID, junk ) : (*iter).second; count += eh - sh + 1; } return count; }
unsigned moab::Range::num_of_type | ( | EntityType | type | ) | const |
Definition at line 889 of file Range.cpp.
{ const_pair_iterator iter = const_pair_begin(); while(iter != const_pair_end() && TYPE_FROM_HANDLE((*iter).second) < type) ++iter; unsigned count = 0; for ( ; iter != const_pair_end(); ++iter) { EntityType start_type = TYPE_FROM_HANDLE((*iter).first); EntityType end_type = TYPE_FROM_HANDLE((*iter).second); if (start_type > type) break; int sid = start_type < type ? 1 : ID_FROM_HANDLE((*iter).first); int eid = end_type > type ? MB_END_ID : ID_FROM_HANDLE((*iter).second); count += eid - sid + 1; } return count; }
just like subtract, but as an operator
Definition at line 722 of file Range.cpp.
{ const bool braindead = false; if (braindead) { // brain-dead implementation right now Range res( *this ); for (Range::const_iterator rit = range2.begin(); rit != range2.end(); rit++) res.erase(*rit); return *this; } else { Range::pair_iterator r_it0 = this->pair_begin(); Range::const_pair_iterator r_it1 = range2.const_pair_begin(); // terminate the while loop when at least one "start" iterator is at the // end of the list while (r_it0 != this->end() && r_it1 != range2.end()) { // case a: pair wholly within subtracted pair if (r_it0->first >= r_it1->first && r_it0->second <= r_it1->second) { Range::PairNode *rtmp = r_it0.node(); r_it0++; this->delete_pair_node(rtmp); } // case b: pair overlaps upper part of subtracted pair else if (r_it0->first <= r_it1->second && r_it0->first >= r_it1->first) { r_it0->first = r_it1->second + 1; r_it1++; } // case c: pair overlaps lower part of subtracted pair else if (r_it0->second >= r_it1->first && r_it0->second <= r_it1->second) { r_it0->second = r_it1->first - 1; r_it0++; } // case d: pair completely surrounds subtracted pair else if (r_it0->first < r_it1->first && r_it0->second > r_it1->second) { Range::PairNode* new_node = alloc_pair(r_it0.node(), r_it0.node()->mPrev, r_it0->first, r_it1->first - 1); new_node->mPrev->mNext = new_node->mNext->mPrev = new_node; r_it0.node()->first = r_it1->second+1; r_it1++; } else { while (r_it0->second < r_it1->first && r_it0 != this->end()) r_it0++; if (r_it0 == this->end()) break; while (r_it1->second < r_it0->first && r_it1 != range2.end()) r_it1++; } } return *this; } }
operator=
Definition at line 201 of file Range.cpp.
{ clear(); const PairNode* copy_node = copy.mHead.mNext; PairNode* new_node = &mHead; for(; copy_node != &(copy.mHead); copy_node = copy_node->mNext) { PairNode* tmp_node = alloc_pair(new_node->mNext, new_node, copy_node->first, copy_node->second); new_node->mNext->mPrev = tmp_node; new_node->mNext = tmp_node; new_node = tmp_node; } return *this; }
EntityHandle moab::Range::operator[] | ( | EntityID | index | ) | const [inline] |
pair_iterator moab::Range::pair_begin | ( | ) | [inline] |
const_pair_iterator moab::Range::pair_begin | ( | ) | const [inline] |
pair_iterator moab::Range::pair_end | ( | ) | [inline] |
const_pair_iterator moab::Range::pair_end | ( | ) | const [inline] |
remove last entity from range
remove first entity from range
void moab::Range::print | ( | const char * | indent_prefix = NULL | ) | const |
for debugging
Definition at line 592 of file Range.cpp.
{ print(std::cout, indent_prefix); }
void moab::Range::print | ( | std::ostream & | s, |
const char * | indent_prefix = NULL |
||
) | const |
Definition at line 597 of file Range.cpp.
{ std::string indent_prefix_str; if (NULL != indent_prefix) indent_prefix_str += indent_prefix; if (empty()) { stream << indent_prefix_str << "\tempty" << std::endl; return; } for (const_pair_iterator i = const_pair_begin(); i != const_pair_end(); ++i) { EntityType t1 = TYPE_FROM_HANDLE( i->first ); EntityType t2 = TYPE_FROM_HANDLE( i->second ); stream << indent_prefix_str << "\t" << CN::EntityTypeName( t1 ) << " " << ID_FROM_HANDLE( i->first ); if(i->first != i->second) { stream << " - "; if (t1 != t2) stream << CN::EntityTypeName( t2 ) << " "; stream << ID_FROM_HANDLE( i->second ); } stream << std::endl; } }
size_t moab::Range::psize | ( | ) | const [inline] |
return the number of range pairs in the list
Definition at line 884 of file Range.hpp.
{ size_t i = 0; Range::const_pair_iterator pit; for (pit = const_pair_begin(), i = 0; pit != const_pair_end(); pit++, i++); return i; }
Range::const_reverse_iterator moab::Range::rbegin | ( | ) | const [inline] |
Range::const_reverse_iterator moab::Range::rend | ( | ) | const [inline] |
void moab::Range::sanity_check | ( | ) | const |
check for internal consistency
Definition at line 561 of file Range.cpp.
{ if(empty()) return; const PairNode* node = mHead.mNext; std::vector<const PairNode*> seen_before; bool stop_it = false; for(; stop_it == false; node = node->mNext) { // have we seen this node before? assert(std::find(seen_before.begin(), seen_before.end(), node) == seen_before.end()); seen_before.push_back(node); // is the connection correct? assert(node->mNext->mPrev == node); // are the values right? assert(node->first <= node->second); if(node != &mHead && node->mPrev != &mHead) assert(node->mPrev->second < node->first); if(node == &mHead) stop_it = true; } }
size_t moab::Range::size | ( | ) | const |
return the number of values this Ranges represents
returns the number of values this list represents
Range moab::Range::subset_by_dimension | ( | int | dim | ) | const |
return a subset of this range, by dimension
return a subset of this range, by type
Definition at line 974 of file Range.cpp.
{ EntityHandle handle1 = CREATE_HANDLE( CN::TypeDimensionMap[d].first, 0 ); iterator st = lower_bound( begin(), end(), handle1 ); iterator en; if (d < 4) { // dimension 4 is MBENTITYSET EntityHandle handle2 = CREATE_HANDLE( CN::TypeDimensionMap[d+1].first, 0 ); en = lower_bound( st, end(), handle2 ); } else { en = end(); } Range result; result.insert( st, en ); return result; }
Range moab::Range::subset_by_type | ( | EntityType | t | ) | const |
void moab::Range::swap | ( | Range & | range | ) |
swap the contents of this range with another one
swap the contents of this range with another one THIS FUNCTION MUST NOT BE INLINED, THAT WILL ELIMINATE RANGE_EMPTY AND THIS_EMPTY BY SUBSTITUTION AND THE FUNCTION WON'T WORK RIGHT!
Definition at line 944 of file Range.cpp.
{ // update next/prev nodes of head of both ranges bool range_empty = (range.mHead.mNext == &(range.mHead)); bool this_empty = (mHead.mNext == &mHead); range.mHead.mNext->mPrev = (range_empty ? &(range.mHead) : &mHead); range.mHead.mPrev->mNext = (range_empty ? &(range.mHead) : &mHead); mHead.mNext->mPrev = (this_empty ? &mHead : &(range.mHead)); mHead.mPrev->mNext = (this_empty ? &mHead : &(range.mHead)); // switch data in head nodes of both ranges PairNode *range_next = range.mHead.mNext, *range_prev = range.mHead.mPrev; range.mHead.mNext = (this_empty ? &(range.mHead) : mHead.mNext); range.mHead.mPrev = (this_empty ? &(range.mHead) : mHead.mPrev); mHead.mNext = (range_empty ? &mHead : range_next); mHead.mPrev = (range_empty ? &mHead : range_prev); }
Range::const_iterator moab::Range::upper_bound | ( | Range::const_iterator | first, |
Range::const_iterator | last, | ||
EntityHandle | val | ||
) | [static] |
const_iterator moab::Range::upper_bound | ( | EntityHandle | val | ) | const [inline] |
Definition at line 301 of file Range.hpp.
{ return upper_bound( begin(), end(), val ); }
Range::const_iterator moab::Range::upper_bound | ( | EntityType | type | ) | const |
Definition at line 846 of file Range.cpp.
{ // if (type+1) overflows, err will be true and we return end(). int err; EntityHandle handle = CREATE_HANDLE( type + 1, 0, err ); return err ? end() : lower_bound( begin(), end(), handle ); }
Range::const_iterator moab::Range::upper_bound | ( | EntityType | type, |
const_iterator | first | ||
) | const |
Definition at line 853 of file Range.cpp.
{ // if (type+1) overflows, err will be true and we return end(). int err; EntityHandle handle = CREATE_HANDLE( type + 1, 0, err ); return err ? end() : lower_bound( first, end(), handle ); }
intersect two ranges, placing the results in the return range
subtract range2 from this, placing the results in the return range
PairNode moab::Range::mHead [protected] |