9
9
#include < limits>
10
10
#include < map>
11
11
#include < optional>
12
- #include < unordered_map >
12
+ #include < ankerl/unordered_dense.h >
13
13
#include < vector>
14
14
15
15
namespace osrm ::util
16
16
{
17
17
18
- template <typename NodeID, typename Key> class GenerationArrayStorage
19
- {
20
- using GenerationCounter = std::uint16_t ;
21
-
22
- public:
23
- explicit GenerationArrayStorage (std::size_t size)
24
- : positions(size, 0 ), generation(1 ), generations(size, 0 )
25
- {
26
- }
27
-
28
- Key &operator [](NodeID node)
29
- {
30
- generation[node] = generation;
31
- return positions[node];
32
- }
33
-
34
- Key peek_index (const NodeID node) const
35
- {
36
- if (generations[node] < generation)
37
- {
38
- return std::numeric_limits<Key>::max ();
39
- }
40
- return positions[node];
41
- }
42
-
43
- void Clear ()
44
- {
45
- generation++;
46
- // if generation overflows we end up at 0 again and need to clear the vector
47
- if (generation == 0 )
48
- {
49
- generation = 1 ;
50
- std::fill (generations.begin (), generations.end (), 0 );
51
- }
52
- }
53
-
54
- private:
55
- GenerationCounter generation;
56
- std::vector<GenerationCounter> generations;
57
- std::vector<Key> positions;
58
- };
59
-
60
18
template <typename NodeID, typename Key> class ArrayStorage
61
19
{
62
20
public:
@@ -98,7 +56,9 @@ template <typename NodeID, typename Key> class MapStorage
98
56
template <typename NodeID, typename Key> class UnorderedMapStorage
99
57
{
100
58
public:
101
- explicit UnorderedMapStorage (std::size_t ) { nodes.rehash (1000 ); }
59
+ explicit UnorderedMapStorage (std::size_t ) {
60
+ nodes.rehash (1000 );
61
+ }
102
62
103
63
Key &operator [](const NodeID node) { return nodes[node]; }
104
64
@@ -121,7 +81,7 @@ template <typename NodeID, typename Key> class UnorderedMapStorage
121
81
void Clear () { nodes.clear (); }
122
82
123
83
private:
124
- std::unordered_map <NodeID, Key> nodes;
84
+ ankerl::unordered_dense::map <NodeID, Key> nodes;
125
85
};
126
86
127
87
template <typename NodeID,
0 commit comments