62 if( ( *i )->using_entire_data() )
availableList.erase( ( *i )->data() );
71 if( j ==
end() || ( *j )->data() != ( *i )->data() || ( *j )->start_handle() > ( *i )->end_handle() + 1 )
74 assert( ( *i )->end_handle() + 1 == ( *j )->start_handle() );
84 if( ( *j )->data() != ( *i )->data() || ( *j )->end_handle() + 1 < ( *i )->start_handle() )
return MB_SUCCESS;
86 assert( ( *j )->end_handle() + 1 == ( *i )->start_handle() );
92 if( !seq_ptr->
data() )
return MB_FAILURE;
127 if( ( *i )->end_handle() < ( *i )->data()->end_handle() )
148 if( ( *i )->start_handle() == ( *i )->data()->start_handle() ||
lower_bound( ( *i )->data()->start_handle() ) == i )
159 if( i ==
end() || ( *i )->data() == seq_ptr->
data() )
return MB_FAILURE;
175 p = ( *i )->data()->seqManData.firstSequence;
176 for( ++n; n !=
end() && ( *n )->data() == ( *i )->data(); ++n )
191 const bool some_before = ( ( *i )->start_handle() < seq_ptr->
start_handle() );
192 const bool some_after = ( ( *i )->end_handle() > seq_ptr->
end_handle() );
194 if( !( some_before || some_after ) )
200 if( p == dead ) p = i;
209 else if( some_before && some_after )
212 ( *i )->pop_front( seq_ptr->
size() );
215 else if( some_after )
217 ( *i )->pop_front( seq_ptr->
size() );
222 ( *i )->pop_back( seq_ptr->
size() );
232 SequenceData* new_data = ( *p )->create_data_subset( ( *p )->start_handle(), ( *last )->end_handle() );
236 ( *p )->data( new_data );
238 dead_data->
move_tag_data( new_data, tag_sizes, num_tag_sizes );
245 SequenceData* new_data = ( *i )->create_data_subset( ( *i )->start_handle(), ( *last )->end_handle() );
248 ( *i )->data( new_data );
250 dead_data->
move_tag_data( new_data, tag_sizes, num_tag_sizes );
278 delete_data = ( j ==
end() || ( *j )->data() != data );
318 unreferenced_data =
true;
322 unreferenced_data = i ==
end() || ( *i )->data() != seq_ptr->
data();
323 if( unreferenced_data )
341 if( ( *( *i )->seqManData.firstSequence )->values_per_entity() != values_per_ent )
continue;
343 if( ( *i )->start_handle() > max_end_handle || ( *i )->end_handle() < min_start_handle )
continue;
345 for(
iterator j = ( *i )->seqManData.firstSequence;
346 j !=
end() && ( *j )->start_handle() <= ( max_end_handle + 1 ) && ( *j )->data() == *i; ++j )
348 if( ( *j )->end_handle() + 1 < min_start_handle )
continue;
349 if( ( *j )->start_handle() > ( *i )->start_handle() && ( *j )->start_handle() > min_start_handle )
354 if( ( *j )->end_handle() < ( *i )->end_handle() && ( *j )->end_handle() < max_end_handle )
371 if(
empty() )
return true;
378 if( ( *i )->data()->end_handle() < start )
return true;
379 data_out = ( *i )->data();
380 if( ( *i )->values_per_entity() != values_per_ent )
return false;
382 return start + num_entities - 1 <= ( *i )->data()->
end_handle();
390 assert( ( *j )->end_handle() < start );
395 if( start + num_entities > ( *i )->start_handle() )
399 if( start + num_entities > ( *i )->data()->start_handle() )
401 data_out = ( *i )->data();
402 if( ( *i )->values_per_entity() != values_per_ent )
return false;
411 if( ( *i )->data()->end_handle() >= start )
413 data_out = ( *i )->data();
414 if( ( *i )->values_per_entity() != values_per_ent )
return false;
415 return start + num_entities - 1 <= ( *i )->data()->
end_handle();
428 if( i ==
end() )
return min_start_handle;
430 if( ( *i )->start_handle() < min_start_handle + num_entities )
return min_start_handle;
434 for( ; i !=
end(); prev_end = ( *i )->end_handle(), ++i )
436 EntityID len = ( *i )->start_handle() - prev_end - 1;
437 if( len >= num_entities )
break;
440 if( prev_end + num_entities > max_end_handle )
474 if( max_end_handle < min_start_handle + num_entities - 1 )
return 0;
478 range_data d = { num_entities, min_start_handle, max_end_handle, 0, 0 };
483 return min_start_handle;
485 else if( i ==
begin() )
487 if( ( *i )->values_per_entity() == num_verts )
489 d.
first = ( *i )->data()->start_handle();
490 d.
last = ( *i )->start_handle() - 1;
493 data_out = ( *i )->data();
497 d.
first = min_start_handle;
498 d.
last = ( *i )->data()->start_handle() - 1;
504 data_size = num_entities;
515 for( ; i !=
end() && ( *i )->start_handle() < max_end_handle; p = i++ )
517 if( ( *p )->data() == ( *i )->data() )
519 if( ( *p )->values_per_entity() == num_verts )
521 d.
first = ( *p )->end_handle() + 1;
522 d.
last = ( *i )->start_handle() - 1;
525 data_out = ( *p )->data();
532 if( ( *p )->values_per_entity() == num_verts )
534 d.
first = ( *p )->end_handle() + 1;
535 d.
last = ( *p )->data()->end_handle();
538 data_out = ( *p )->data();
542 if( ( *i )->values_per_entity() == num_verts )
544 d.
first = ( *i )->data()->start_handle();
545 d.
last = ( *i )->start_handle() - 1;
548 data_out = ( *i )->data();
552 d.
first = ( *p )->data()->end_handle() + 1;
553 d.
last = ( *i )->data()->start_handle() - 1;
563 if( ( *p )->values_per_entity() == num_verts )
565 d.
first = ( *p )->end_handle() + 1;
566 d.
last = ( *p )->data()->end_handle();
569 data_out = ( *p )->data();
574 d.
first = ( *p )->data()->end_handle() + 1;
575 d.
last = max_end_handle;
592 else if( ( *it )->start_handle() > after_this )
607 if( i ==
end() || ( *i )->start_handle() >
first )
614 "[Warning]: Invalid entity handle: 0x%lx\n", (
unsigned long)
first
620 while( ( *i )->end_handle() < last )
640 "[Warning]: Invalid entity handle: 0x%lx\n", (
unsigned long)h
659 if( delete_data )
delete data;
669 if( ( *i )->using_entire_data() )
availableList.insert( ( *i )->data() );
694 if( ( *i )->start_handle() <
first && ( *i )->end_handle() > last )
696 if( ( *i )->using_entire_data() )
availableList.insert( ( *i )->data() );
698 ( *i )->pop_front( last -
first + 1 );
706 if( ( *i )->start_handle() <
first )
708 if( ( *i )->using_entire_data() )
availableList.insert( ( *i )->data() );
709 ( *i )->pop_back( ( *i )->end_handle() -
first + 1 );
714 while( i !=
end() && ( *i )->end_handle() <= last )
719 if( i !=
end() && ( *i )->start_handle() <= last )
721 if( ( *i )->using_entire_data() )
availableList.insert( ( *i )->data() );
722 ( *i )->pop_front( last - ( *i )->start_handle() + 1 );
732 if( !seq )
return end();
754 block_end = ( *i )->start_handle() - 1;
761 if( ( *i )->data()->start_handle() <= handle )
767 data_ptr_out = ( *i )->data();
768 if( block_end == handle )
772 block_start = handle;
777 seq_iter_out =
end();
778 if( i ==
begin() || ( *--i )->data() != data_ptr_out )
781 block_start = ( *i )->end_handle() + 1;
790 block_start = ( *i )->end_handle() + 1;
793 if( ( *i )->data()->end_handle() >= handle )
799 data_ptr_out = ( *i )->data();
800 if( block_start == handle )
809 seq_iter_out =
end();
810 if( ++i ==
end() || ( *i )->data() != data_ptr_out )
813 block_end = ( *i )->start_handle() - 1;
819 seq_iter_out =
end();
828 if( ( *seq )->using_entire_data() )
availableList.erase( ( *seq )->data() );
836 if( ( *seq )->using_entire_data() )
availableList.erase( ( *seq )->data() );
843 entity_storage = total_storage = 0;
844 if(
empty() )
return;
849 entity_storage, total_storage );
855 unsigned long long& entity_storage,
856 unsigned long long& total_storage )
const
858 const unsigned long allocated_count = data->
size();
860 unsigned long bytes_per_ent, seq_size;
862 ( *i )->get_const_memory_use( bytes_per_ent, seq_size );
864 unsigned long other_ent_mem = 0;
865 unsigned long occupied_count = 0, entity_count = 0, sequence_count = 0;
866 for( ; i !=
end() && ( *i )->data() == data; ++i )
868 occupied_count += ( *i )->size();
872 EntityHandle stop = std::min( last, ( *i )->end_handle() );
873 if( stop < start )
continue;
875 entity_count += stop - start + 1;
876 other_ent_mem += ( *i )->get_per_entity_memory_use( start, stop );
879 unsigned long sum = sequence_count * seq_size + allocated_count * bytes_per_ent;
882 assert( entity_count > 0 && occupied_count > 0 && allocated_count > 0 );
883 if( std::numeric_limits< unsigned long >::max() / entity_count <=
sum )
885 total_storage +=
sum * ( entity_count / occupied_count ) + other_ent_mem;
886 entity_storage +=
sum * ( entity_count / allocated_count ) + other_ent_mem;
890 total_storage +=
sum * entity_count / occupied_count + other_ent_mem;
891 entity_storage +=
sum * entity_count / allocated_count + other_ent_mem;
897 unsigned long long& entity_storage,
898 unsigned long long& total_storage )
const
900 entity_storage = total_storage = 0;
902 while(
first <= last )
905 if( i ==
end() )
return;
908 if( first < data->end_handle() )
920 result += ( *i )->size();
929 if(
empty() )
return false;
939 if( seq2 != seq )
return false;
950 if( ( *j )->end_handle() >= data->
start_handle() )
return false;
951 if( ( *j )->data()->end_handle() >= data->
start_handle() )
return false;
958 if( i ==
end() )
return true;
959 if( ( *i )->data() != data )
break;
961 if( seq2->
end_handle() >= ( *i )->start_handle() )
return false;
964 if( ( *i )->start_handle() <= data->
end_handle() )
return false;
965 if( ( *i )->data()->start_handle() <= data->
end_handle() )
return false;