MCPcopy Create free account
hub / github.com/apache/brpc / list_flat_map

Function list_flat_map

test/flat_map_unittest.cpp:580–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578
579template <typename Key, typename Value, typename OnPause>
580static void list_flat_map(std::vector<Key>* keys,
581 const butil::FlatMap<Key, Value>& map,
582 size_t max_one_pass,
583 OnPause& on_pause) {
584 keys->clear();
585 typedef butil::FlatMap<Key, Value> Map;
586 size_t n = 0;
587 for (typename Map::const_iterator it = map.begin(); it != map.end(); ++it) {
588 if (++n >= max_one_pass) {
589 typename Map::PositionHint hint;
590 map.save_iterator(it, &hint);
591 n = 0;
592 on_pause(hint);
593 it = map.restore_iterator(hint);
594 if (it == map.begin()) { // resized
595 keys->clear();
596 }
597 if (it == map.end()) {
598 break;
599 }
600 }
601 keys->push_back(it->first);
602 }
603}
604
605typedef butil::FlatMap<uint64_t, uint64_t> PositionHintMap;
606

Callers 1

TEST_FFunction · 0.85

Calls 6

save_iteratorMethod · 0.80
restore_iteratorMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected