MCPcopy Create free account
hub / github.com/apache/arrow / GetOrInsertGenerated

Function GetOrInsertGenerated

cpp/src/arrow/util/map_internal.h:32–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30/// invoked and its return value inserted.
31template <typename Map, typename Gen>
32auto GetOrInsertGenerated(Map* map, typename Map::key_type key, Gen&& gen)
33 -> decltype(map->begin()->second = gen(map->begin()->first), map->begin()) {
34 decltype(gen(map->begin()->first)) placeholder{};
35
36 auto it_success = map->emplace(std::move(key), std::move(placeholder));
37 if (it_success.second) {
38 // insertion of placeholder succeeded, overwrite it with gen()
39 const auto& inserted_key = it_success.first->first;
40 auto* value = &it_success.first->second;
41 *value = gen(inserted_key);
42 }
43 return it_success.first;
44}
45
46template <typename Map, typename Gen>
47auto GetOrInsertGenerated(Map* map, typename Map::key_type key, Gen&& gen)

Callers

nothing calls this directly

Calls 4

ValueOrDieMethod · 0.80
genFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
beginMethod · 0.45

Tested by

no test coverage detected