MCPcopy Create free account
hub / github.com/apple/foundationdb / insert

Method insert

fdbrpc/TokenCache.actor.cpp:48–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47 template <class K, class V>
48 mapped_type* insert(K&& key, V&& value) {
49 auto iter = _map.find(key);
50 if (iter != _map.end()) {
51 return &iter->second.first;
52 }
53 if (size() == capacity()) {
54 auto i = --_list.end();
55 _map.erase(*i);
56 _list.erase(i);
57 }
58 _list.push_front(std::forward<K>(key));
59 std::tie(iter, std::ignore) =
60 _map.insert(std::make_pair(*_list.begin(), std::make_pair(std::forward<V>(value), _list.begin())));
61 return &iter->second.first;
62 }
63
64private:
65 const size_type _capacity;

Callers 2

validateAndAddMethod · 0.45

Calls 5

sizeFunction · 0.50
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected