MCPcopy Create free account
hub / github.com/dengwirda/jigsaw / inc_count

Method inc_count

src/libcpp/containers/block_array.hpp:375–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373 */
374
375 __normal_call void_type inc_count ( // _def-construct
376 size_type _inc_count ,
377 __cont::alloc_types _new_alloc =
378 __cont::loose_alloc
379 )
380 {
381 size_type _cur_count = count() ;
382 size_type _new_count = count() +
383 _inc_count ;
384
385 size_type _cur_block = +0;
386 size_type _new_block = +0;
387 size_type _end_shift = +0;
388
389 size_type _siz_block = _size ;
390
391 /*------------------ calc. block-wise storage offsets */
392 if (_cur_count!=+0)
393 {
394 _cur_block =
395 (_cur_count - 1) / _size + 0;
396 }
397 if (_new_count!=+0)
398 {
399 _new_block =
400 (_new_count - 1) / _size + 0;
401 _end_shift =
402 (_new_count - 1) % _size + 1;
403 }
404
405 /*--------- expand underlying buffer, based on policy */
406 switch (_new_alloc )
407 {
408 case __cont::loose_alloc :
409 { inc_alloc(_cur_count + _inc_count); break ; }
410 case __cont::tight_alloc :
411 { set_alloc(_cur_count + _inc_count); break ; }
412 }
413 /*--------- update block structure and ctor new items */
414 for(size_type _pos_block = _cur_block;
415 _pos_block < _new_block;
416 ++_pos_block )
417 {
418 this->_block [_pos_block].set_count(
419 _siz_block, __cont::loose_alloc) ;
420 }
421 if (_new_count!=+0)
422 {
423 this->_block [_new_block].set_count(
424 _end_shift, __cont::loose_alloc) ;
425 }
426
427 this->_count =_new_count ;
428 }
429
430 /*
431 --------------------------------------------------------

Callers

nothing calls this directly

Calls 1

set_countMethod · 0.45

Tested by

no test coverage detected