| 69 | } |
| 70 | |
| 71 | void HashTable::IdsAllocator::GetIds(int64 count, IdsContainer* ids) { |
| 72 | count -= ids->Size(); |
| 73 | if (count <= 0) return; |
| 74 | if (free_list_.empty()) { |
| 75 | ids->region_list_.emplace_back(); |
| 76 | ids->region_list_.back().start = counter_; |
| 77 | counter_ += count; |
| 78 | ids->region_list_.back().end = counter_; |
| 79 | return; |
| 80 | } |
| 81 | int64 from_list = count <= free_list_.size() ? count : free_list_.size(); |
| 82 | ids->id_list_.insert(ids->id_list_.end(), |
| 83 | free_list_.begin(), free_list_.begin() + from_list); |
| 84 | free_list_.erase(free_list_.begin(), free_list_.begin() + from_list); |
| 85 | |
| 86 | int64 left = count - from_list; |
| 87 | if (left <= 0) return; |
| 88 | ids->region_list_.emplace_back(); |
| 89 | ids->region_list_.back().start = counter_; |
| 90 | counter_ += left; |
| 91 | ids->region_list_.back().end = counter_; |
| 92 | } |
| 93 | |
| 94 | void HashTable::IdsAllocator::GetId(int64* id) { |
| 95 | if (free_list_.empty()) { |