| 495 | */ |
| 496 | |
| 497 | __normal_call void_type dec_count ( |
| 498 | size_type _dec_count, |
| 499 | __cont::alloc_types _new_alloc = |
| 500 | __cont::loose_alloc |
| 501 | ) |
| 502 | { |
| 503 | size_type _cur_count = count() ; |
| 504 | size_type _new_count = count() - |
| 505 | _dec_count ; |
| 506 | |
| 507 | size_type _nil_block = +0; |
| 508 | |
| 509 | size_type _cur_block = +0; |
| 510 | size_type _new_block = +0; |
| 511 | size_type _end_shift = +0; |
| 512 | |
| 513 | /*------------------ calc. block-wise storage offsets */ |
| 514 | if (_cur_count!=+0) |
| 515 | { |
| 516 | _cur_block = |
| 517 | (_cur_count - 1) / _size + 0 ; |
| 518 | } |
| 519 | if (_new_count!=+0) |
| 520 | { |
| 521 | _new_block = |
| 522 | (_new_count - 1) / _size + 0 ; |
| 523 | _end_shift = |
| 524 | (_new_count - 1) % _size + 1 ; |
| 525 | } |
| 526 | |
| 527 | /*--------- update block structure and ctor new items */ |
| 528 | for(size_type _pos_block = _cur_block; |
| 529 | _pos_block > _new_block; |
| 530 | --_pos_block ) |
| 531 | { |
| 532 | this->_block [_pos_block].set_count( |
| 533 | _nil_block, __cont::loose_alloc) ; |
| 534 | } |
| 535 | if (_cur_count!=+0) |
| 536 | { |
| 537 | this->_block [_new_block].set_count( |
| 538 | _end_shift, __cont::loose_alloc) ; |
| 539 | } |
| 540 | |
| 541 | this->_count =_new_count ; |
| 542 | |
| 543 | /*--------- shrink underlying buffer, based on policy */ |
| 544 | switch (_new_alloc ) |
| 545 | { |
| 546 | case __cont::loose_alloc : |
| 547 | { /* do nothing - preserve buffer */ break ; } |
| 548 | case __cont::tight_alloc : |
| 549 | { set_alloc(_cur_count - _dec_count); break ; } |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | /* |
| 554 | -------------------------------------------------------- |