note: it shouldn't touch 'value' if it returns false.
| 556 | |
| 557 | // note: it shouldn't touch 'value' if it returns false. |
| 558 | bool PickOut(const TKey& key, TValue* value) { |
| 559 | Y_ASSERT(value); |
| 560 | TIndexIterator it = Index.find(key); |
| 561 | if (it == Index.end()) |
| 562 | return false; |
| 563 | *value = std::move(it->Value); |
| 564 | List.Erase(const_cast<TItem*>(&*it)); |
| 565 | Index.erase(it); |
| 566 | Y_ASSERT(Index.size() == List.GetSize()); |
| 567 | return true; |
| 568 | } |
| 569 | |
| 570 | bool Insert(const std::pair<TKey, TValue>& p) { |
| 571 | return Insert(p.first, p.second); |