mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-30 00:50:38 +08:00
Merged with upstream repo.
This commit is contained in:
@@ -21,7 +21,7 @@ This repository aims to provide a set of excellent **hash map** implementations,
|
||||
|
||||
- Easy to **forward declare**: just include `phmap_fwd_decl.h` in your header files to forward declare Parallel Hashmap containers [note: this does not work currently for hash maps with pointer keys]
|
||||
|
||||
- **Dump/load** feature: when a hash map stores data that is `std::trivially_copyable`, the table can be dumped to disk and restored as a single array, very efficiently, and without requiring any hash computation. This is typically about 10 times faster than doing element-wise serialization to disk, but it will use 10% to 60% extra disk space. See `examples/serialize.cc`. _(hash map/set only)_
|
||||
- **Dump/load** feature: when a `flat` hash map stores data that is `std::trivially_copyable`, the table can be dumped to disk and restored as a single array, very efficiently, and without requiring any hash computation. This is typically about 10 times faster than doing element-wise serialization to disk, but it will use 10% to 60% extra disk space. See `examples/serialize.cc`. _(flat hash map/set only)_
|
||||
|
||||
- **Tested** on Windows (vs2015 & vs2017, vs2019, Intel compiler 18 and 19), linux (g++ 4.8.4, 5, 6, 7, 8, clang++ 3.9, 4.0, 5.0) and MacOS (g++ and clang++) - click on travis and appveyor icons above for detailed test status.
|
||||
|
||||
|
||||
Vendored
-13
@@ -54,25 +54,12 @@
|
||||
#pragma warning(disable : 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
|
||||
#endif
|
||||
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
|
||||
#include "phmap_fwd_decl.h"
|
||||
#include "phmap_base.h"
|
||||
|
||||
Vendored
+2
@@ -3434,6 +3434,8 @@ public:
|
||||
return modify_if_impl<K, F, Lockable::UniqueLock>(key, std::forward<F>(f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class K = key_type, class P = Policy, K* = nullptr>
|
||||
MappedReference<P> operator[](key_arg<K>&& key) {
|
||||
return Policy::value(&*try_emplace(std::forward<K>(key)).first);
|
||||
|
||||
@@ -13,13 +13,20 @@ TEST(THIS_TEST_NAME, ThreadSafeContains) {
|
||||
// We can't test mutable keys, or non-copyable keys with ThisMap.
|
||||
// Test that the nodes have the proper API.
|
||||
ThisMap<int, int> m = { {1, 7}, {2, 9} };
|
||||
auto val = 0;
|
||||
|
||||
auto func = [&val](int& v) { val = v; };
|
||||
EXPECT_TRUE(m.if_contains(2, func));
|
||||
const ThisMap<int, int>& const_m(m);
|
||||
|
||||
auto val = 0;
|
||||
auto get_value = [&val](const int& v) { val = v; };
|
||||
EXPECT_TRUE(const_m.if_contains(2, get_value));
|
||||
EXPECT_EQ(val, 9);
|
||||
|
||||
EXPECT_FALSE(m.if_contains(3, func));
|
||||
EXPECT_FALSE(m.if_contains(3, get_value));
|
||||
|
||||
auto set_value = [&val](int& v) { v = 11; };
|
||||
EXPECT_TRUE(m. modify_if(2, set_value));
|
||||
EXPECT_EQ(m[2], 11);
|
||||
|
||||
EXPECT_FALSE(m.modify_if(3, set_value));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user