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:
@@ -72,29 +30,6 @@ template <typename NodeID, typename Key> class ArrayStorage
72
30
std::vector<Key> positions;
73
31
};
74
32
75
- template <typename NodeID, typename Key> class MapStorage
76
- {
77
- public:
78
- explicit MapStorage (std::size_t ) {}
79
-
80
- Key &operator [](NodeID node) { return nodes[node]; }
81
-
82
- void Clear () { nodes.clear (); }
83
-
84
- Key peek_index (const NodeID node) const
85
- {
86
- const auto iter = nodes.find (node);
87
- if (nodes.end () != iter)
88
- {
89
- return iter->second ;
90
- }
91
- return std::numeric_limits<Key>::max ();
92
- }
93
-
94
- private:
95
- std::map<NodeID, Key> nodes;
96
- };
97
-
98
33
template <typename NodeID, typename Key> class UnorderedMapStorage
99
34
{
100
35
public:
0 commit comments