38 #ifdef HAVE_BOOST_POOL_SINGLETON_POOL_HPP
39 #include <boost/pool/singleton_pool.hpp>
53 PairAlloc::free( node );
84 sz += ( ( iter->second - iter->first ) + 1 );
105 if( this_node_rem >= step )
110 step -= this_node_rem + 1;
115 EntityHandle node_size = node->second - node->first + 1;
116 while( step >= node_size )
120 node_size = node->second - node->first + 1;
138 return operator+=( -sstep );
146 if( this_node_rem >= step )
151 step -= this_node_rem + 1;
156 EntityHandle node_size = node->second - node->first + 1;
157 while( step >= node_size )
161 node_size = node->second - node->first + 1;
167 mValue = mNode->second - step;
187 for( ; copy_node != &( copy.
mHead ); copy_node = copy_node->
mNext )
191 new_node->
mNext = tmp_node;
200 while( tmp_node != &
mHead )
203 tmp_node = tmp_node->
mNext;
215 for( ; copy_node != &( copy.
mHead ); copy_node = copy_node->
mNext )
219 new_node->
mNext = tmp_node;
232 if( val == 0 )
return end();
245 for( ; ( jter != &
mHead ) && ( jter->second < val ); jter = jter->
mNext )
251 if( ( iter->first <= val && iter->second >= val ) && ( iter != &
mHead ) )
263 else if( ( iter->first == ( val + 1 ) ) && ( iter != &
mHead ) )
267 if( ( iter !=
mHead.
mNext ) && ( jter->second == ( val - 1 ) ) )
269 jter->second = iter->second;
281 else if( ( jter->second == ( val - 1 ) ) && ( iter !=
mHead.
mNext ) )
297 if( val1 == 0 || val1 > val2 )
return end();
302 assert( prev ==
end() );
330 while( iter != &
mHead && iter->second + 1 < val1 )
334 if( iter == &
mHead || iter->first - 1 > val2 )
342 if( iter->first > val1 ) iter->first = val1;
343 if( iter->second >= val2 )
return iterator( iter, val1 );
353 if( dead->second > val2 ) iter->second = dead->second;
371 if( iter ==
end() )
return end();
380 if( kter->first == kter->second )
388 else if( kter->first == iter.
mValue )
394 else if( kter->second == iter.
mValue )
430 if( iter1.
mValue == node->first )
432 node->first = iter2.
mValue;
440 node->second = iter1.
mValue - 1;
441 result =
iterator( new_node, new_node->first );
448 if( iter1.
mValue > dn->first )
450 dn->second = iter1.
mValue - 1;
454 while( dn != iter2.
mNode )
514 for( ; iter != &
mHead && ( val > iter->second ); iter = iter->
mNext )
516 return ( ( iter->second >= val ) && ( iter->first <= val ) ) ?
const_iterator( iter, val ) :
end();
525 if( begini == endi )
return;
528 if( endi.
mNode == node )
530 insert( *begini, ( *endi ) - 1 );
536 while( node != endi.
mNode )
538 hint =
insert( hint, node->first, node->second );
542 if( *endi > node->first )
544 if( *endi <= node->second )
545 insert( hint, node->first, *(endi)-1 );
547 insert( hint, node->first, node->second );
556 if(
empty() )
return;
559 std::vector< const PairNode* > seen_before;
560 bool stop_it =
false;
562 for( ; stop_it ==
false; node = node->
mNext )
565 assert( std::find( seen_before.begin(), seen_before.end(), node ) == seen_before.end() );
566 seen_before.push_back( node );
572 assert( node->first <= node->second );
575 if( node == &
mHead ) stop_it =
true;
581 std::stringstream str_stream;
582 std::string indent_prefix_str;
583 if( NULL != indent_prefix )
585 indent_prefix_str += indent_prefix;
590 str_stream << indent_prefix_str <<
"\tempty" << std::endl;
591 return str_stream.str().c_str();
600 if( i->first != i->second )
606 str_stream << std::endl;
609 return str_stream.str();
612 void Range::print( std::ostream& stream,
const char* indent_prefix )
const
614 stream <<
str_rep( indent_prefix );
620 print( std::cout, indent_prefix );
624 #define MAX( a, b ) ( ( a ) < ( b ) ? ( b ) : ( a ) )
625 #define MIN( a, b ) ( ( a ) > ( b ) ? ( b ) : ( a ) )
636 while( r_it[0] != range1.
end() && r_it[1] != range2.
end() )
639 if( r_it[0]->second < r_it[1]->
first )
642 else if( r_it[1]->second < r_it[0]->
first )
650 high_it =
MIN( r_it[0]->second, r_it[1]->second );
653 hint = lhs.
insert( hint, low_it, high_it );
656 if( high_it == r_it[0]->second ) ++r_it[0];
657 if( high_it == r_it[1]->second ) ++r_it[1];
666 const bool braindead =
false;
686 while( r_it0 != lhs.
end() && r_it1 != range2.
end() )
689 if( r_it0->first >= r_it1->first && r_it0->second <= r_it1->second )
696 else if( r_it0->first <= r_it1->second && r_it0->first >= r_it1->first )
698 r_it0->first = r_it1->second + 1;
702 else if( r_it0->second >= r_it1->first && r_it0->second <= r_it1->second )
704 r_it0->second = r_it1->first - 1;
708 else if( r_it0->first < r_it1->first && r_it0->second > r_it1->second )
713 r_it0.
node()->first = r_it1->second + 1;
718 while( r_it0->second < r_it1->first && r_it0 != lhs.
end() )
720 if( r_it0 == lhs.
end() )
break;
721 while( r_it1->second < r_it0->first && r_it1 != range2.
end() )
732 const bool braindead =
false;
750 while( r_it0 != this->
end() && r_it1 != range2.
end() )
753 if( r_it0->first >= r_it1->first && r_it0->second <= r_it1->second )
760 else if( r_it0->first <= r_it1->second && r_it0->first >= r_it1->first )
762 r_it0->first = r_it1->second + 1;
766 else if( r_it0->second >= r_it1->first && r_it0->second <= r_it1->second )
768 r_it0->second = r_it1->first - 1;
772 else if( r_it0->first < r_it1->first && r_it0->second > r_it1->second )
777 r_it0.
node()->first = r_it1->second + 1;
782 while( r_it0->second < r_it1->first && r_it0 != this->end() )
784 if( r_it0 == this->
end() )
break;
785 while( r_it1->second < r_it0->first && r_it1 != range2.
end() )
795 assert( !it2.
mValue || *it2 >= *it1 );
803 result += n->second - n->first + 1;
815 if( iter->second >= val )
819 if( iter->first > val )
return const_iterator( iter, iter->first );
824 if( iter->first >= val )
826 else if( *last > val )
835 if( result != last && *result == val ) ++result;
867 std::pair< Range::const_iterator, Range::const_iterator >
Range::equal_range( EntityType type )
const
869 std::pair< Range::const_iterator, Range::const_iterator > result;
901 if( start_type > type )
break;
905 count += eid - sid + 1;
923 if( start_dim >
dim )
break;
928 count += eh - sh + 1;
960 std::pair< const_iterator, const_iterator > iters =
equal_range( t );
961 result.
insert( iters.first, iters.second );
993 if( i2 == r2.
const_pair_end() || i1->first != i2->first || i1->second != i2->second )
return false;
999 unsigned long result = 0;
1007 if( othr.
empty() )
return true;
1008 if(
empty() )
return false;
1018 while( this_node->second < othr_node->first )
1020 this_node = this_node->
mNext;
1021 if( this_node == &
mHead )
return false;
1025 if( this_node->first > othr_node->first )
break;
1027 while( othr_node->second <= this_node->second )
1029 othr_node = othr_node->
mNext;
1030 if( othr_node == &othr.
mHead )
return true;
1033 if( othr_node->first <= this_node->second )
break;