mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 08:34:39 +08:00
Fix example to reflect new usage of lazy_emplace_l - issue #143
This commit is contained in:
Vendored
+3
@@ -138,6 +138,9 @@ if (PHMAP_BUILD_EXAMPLES)
|
||||
add_executable(ex_basic examples/basic.cc phmap.natvis)
|
||||
add_executable(ex_bench examples/bench.cc phmap.natvis)
|
||||
add_executable(ex_emplace examples/emplace.cc phmap.natvis)
|
||||
if (MSVC)
|
||||
add_executable(ex_lazy_emplace_l examples/lazy_emplace_l.cc phmap.natvis)
|
||||
endif()
|
||||
add_executable(ex_serialize examples/serialize.cc phmap.natvis)
|
||||
target_include_directories(ex_serialize PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../cereal/include>)
|
||||
add_executable(ex_hash_std examples/hash_std.cc phmap.natvis)
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
{
|
||||
int newIndex = -1;
|
||||
m_stringsMap.lazy_emplace_l(std::move(str),
|
||||
[&](int& v) { newIndex = v; }, // called only when key was already present
|
||||
[&](Map::value_type& p) { newIndex = p.second; }, // called only when key was already present
|
||||
[&](const Map::constructor& ctor) // construct value_type in place when key not present
|
||||
{ newIndex = InterlockedIncrement(curIdx); ctor(std::move(str), newIndex); });
|
||||
|
||||
|
||||
Vendored
+3
-3
@@ -3276,10 +3276,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// if map does not contains key, it is inserted and the mapped value is value-constructed
|
||||
// with the provided arguments (if any), as with try_emplace.
|
||||
// if map already contains key, then the lambda is called with the mapped value (under
|
||||
// if map already contains key, the first lambda is called with the mapped value (under
|
||||
// write lock protection) and can update the mapped value.
|
||||
// if map does not contains key, the second lambda is called and it should invoke the
|
||||
// passed constructor to construct the value
|
||||
// returns true if key was not already present, false otherwise.
|
||||
// ---------------------------------------------------------------------------------------
|
||||
template <class K = key_type, class FExists, class FEmplace>
|
||||
|
||||
Reference in New Issue
Block a user