32
32
#include < optional>
33
33
#include < utility>
34
34
35
- #ifdef USE_ROBIN_HOOD_HASHING
36
- #include " robin_hood .h"
35
+ #ifdef USE_UNORDERED_DENSE
36
+ #include " ankerl/unordered_dense .h"
37
37
#else
38
38
#include < unordered_set>
39
39
#endif
40
40
41
41
// namespace aliases to allow map and set implementations to easily be swapped out
42
42
namespace vvl {
43
43
44
- #ifdef USE_ROBIN_HOOD_HASHING
44
+ #ifdef USE_UNORDERED_DENSE
45
45
template <typename T>
46
- using hash = robin_hood ::hash<T>;
46
+ using hash = ankerl::unordered_dense ::hash<T>;
47
47
48
- template <typename Key, typename Hash = robin_hood ::hash<Key>, typename KeyEqual = std::equal_to<Key>>
49
- using unordered_set = robin_hood::unordered_set <Key, Hash, KeyEqual>;
48
+ template <typename Key, typename Hash = ankerl::unordered_dense ::hash<Key>, typename KeyEqual = std::equal_to<Key>>
49
+ using unordered_set = ankerl::unordered_dense::set <Key, Hash, KeyEqual>;
50
50
51
- template <typename Key, typename T, typename Hash = robin_hood ::hash<Key>, typename KeyEqual = std::equal_to<Key>>
52
- using unordered_map = robin_hood::unordered_map <Key, T, Hash, KeyEqual>;
51
+ template <typename Key, typename T, typename Hash = ankerl::unordered_dense ::hash<Key>, typename KeyEqual = std::equal_to<Key>>
52
+ using unordered_map = ankerl::unordered_dense::segmented_map <Key, T, Hash, KeyEqual>;
53
53
54
54
template <typename Key, typename T>
55
- using map_entry = robin_hood::pair<Key, T>;
56
-
57
- // robin_hood-compatible insert_iterator (std:: uses the wrong insert method)
58
- // NOTE: std::iterator was deprecated in C++17, and newer versions of libstdc++ appear to mark this as such.
59
- template <typename T>
60
- struct insert_iterator {
61
- using iterator_category = std::output_iterator_tag;
62
- using value_type = typename T::value_type;
63
- using iterator = typename T::iterator;
64
- using difference_type = void ;
65
- using pointer = void ;
66
- using reference = T &;
67
-
68
- insert_iterator (reference t, iterator i) : container(&t), iter(i) {}
69
-
70
- insert_iterator &operator =(const value_type &value) {
71
- auto result = container->insert (value);
72
- iter = result.first ;
73
- ++iter;
74
- return *this ;
75
- }
76
-
77
- insert_iterator &operator =(value_type &&value) {
78
- auto result = container->insert (std::move (value));
79
- iter = result.first ;
80
- ++iter;
81
- return *this ;
82
- }
83
-
84
- insert_iterator &operator *() { return *this ; }
85
-
86
- insert_iterator &operator ++() { return *this ; }
87
-
88
- insert_iterator &operator ++(int ) { return *this ; }
89
-
90
- private:
91
- T *container;
92
- iterator iter;
93
- };
55
+ using map_entry = std::pair<Key, T>;
94
56
#else
95
57
template <typename T>
96
58
using hash = std::hash<T>;
@@ -103,9 +65,6 @@ using unordered_map = std::unordered_map<Key, T, Hash, KeyEqual>;
103
65
104
66
template <typename Key, typename T>
105
67
using map_entry = std::pair<Key, T>;
106
-
107
- template <typename T>
108
- using insert_iterator = std::insert_iterator<T>;
109
68
#endif
110
69
111
70
} // namespace vvl
0 commit comments