MCPcopy Create free account
hub / github.com/apache/impala / ComputePairIfAbsentReturnAbsense

Function ComputePairIfAbsentReturnAbsense

be/src/gutil/map-util.h:930–944  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928// });
929template <class MapContainer, typename Function>
930std::pair<typename MapContainer::mapped_type* const, bool>
931ComputePairIfAbsentReturnAbsense(MapContainer* container,
932 const typename MapContainer::key_type& key,
933 Function compute_pair_func) {
934 typename MapContainer::iterator iter = container->find(key);
935 bool new_value = iter == container->end();
936 if (new_value) {
937 auto p = compute_pair_func();
938 std::pair<typename MapContainer::iterator, bool> result =
939 container->emplace(std::move(p.first), std::move(p.second));
940 DCHECK(result.second) << "duplicate key: " << key;
941 iter = result.first;
942 }
943 return std::make_pair(&iter->second, new_value);
944}
945template <class MapContainer, typename Function>
946std::pair<typename MapContainer::mapped_type* const, bool>
947ComputeIfAbsentReturnAbsense(MapContainer* container,

Callers 2

TESTFunction · 0.85

Calls 3

moveFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.68