| 537 | typename KeyOfValue = DefaultKeyValue<Value*>, |
| 538 | typename Cmp = ObjectComparator<const Key*> > |
| 539 | class PointersArray |
| 540 | { |
| 541 | private: |
| 542 | Array<Value, Storage> values; |
| 543 | SortedArray<Value*, InlineStorage<Value*, 8>, const Key*, KeyOfValue, Cmp> pointers; |
| 544 | |
| 545 | void checkPointers(const Value* oldBegin) |
| 546 | { |
| 547 | Value* newBegin = values.begin(); |
| 548 | if (newBegin != oldBegin) |
| 549 | { |
| 550 | for (Value** ptr = pointers.begin(); ptr < pointers.end(); ++ptr) |
| 551 | { |
| 552 | *ptr = newBegin + (*ptr - oldBegin); |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | public: |
| 558 | typedef FB_SIZE_T size_type; |
| 559 | |
| 560 | class const_iterator |
| 561 | { |
| 562 | private: |
| 563 | const Value* const* ptr; |
| 564 | |
| 565 | public: |
| 566 | const_iterator() : ptr(NULL) { } |
| 567 | const_iterator(const const_iterator& it) : ptr(it.ptr) { } |
| 568 | explicit const_iterator(const PointersArray& a) : ptr(a.pointers.begin()) { } |
| 569 | |
| 570 | const_iterator& operator++() |
| 571 | { |
| 572 | fb_assert(ptr); |
| 573 | ptr++; |
| 574 | return *this; |
| 575 | } |
| 576 | |
| 577 | const_iterator operator++(int) |
| 578 | { |
| 579 | fb_assert(ptr); |
| 580 | const_iterator tmp = *this; |
| 581 | ptr++; |
| 582 | return tmp; |
| 583 | } |
| 584 | |
| 585 | const_iterator& operator--() |
| 586 | { |
| 587 | fb_assert(ptr); |
| 588 | ptr--; |
| 589 | return *this; |
| 590 | } |
| 591 | |
| 592 | const_iterator operator--(int) |
| 593 | { |
| 594 | fb_assert(ptr); |
| 595 | const_iterator tmp = *this; |
| 596 | ptr--; |