Skip to content

Commit

Permalink
Remove unused MapStorage and GenerationArrayStorage (#6990)
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou authored Jul 11, 2024
1 parent 825132e commit c2f877e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 68 deletions.
65 changes: 0 additions & 65 deletions include/util/query_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,6 @@
namespace osrm::util
{

template <typename NodeID, typename Key> class GenerationArrayStorage
{
using GenerationCounter = std::uint16_t;

public:
explicit GenerationArrayStorage(std::size_t size)
: positions(size, 0), generation(1), generations(size, 0)
{
}

Key &operator[](NodeID node)
{
generation[node] = generation;
return positions[node];
}

Key peek_index(const NodeID node) const
{
if (generations[node] < generation)
{
return std::numeric_limits<Key>::max();
}
return positions[node];
}

void Clear()
{
generation++;
// if generation overflows we end up at 0 again and need to clear the vector
if (generation == 0)
{
generation = 1;
std::fill(generations.begin(), generations.end(), 0);
}
}

private:
GenerationCounter generation;
std::vector<GenerationCounter> generations;
std::vector<Key> positions;
};

template <typename NodeID, typename Key> class ArrayStorage
{
public:
Expand All @@ -72,29 +30,6 @@ template <typename NodeID, typename Key> class ArrayStorage
std::vector<Key> positions;
};

template <typename NodeID, typename Key> class MapStorage
{
public:
explicit MapStorage(std::size_t) {}

Key &operator[](NodeID node) { return nodes[node]; }

void Clear() { nodes.clear(); }

Key peek_index(const NodeID node) const
{
const auto iter = nodes.find(node);
if (nodes.end() != iter)
{
return iter->second;
}
return std::numeric_limits<Key>::max();
}

private:
std::map<NodeID, Key> nodes;
};

template <typename NodeID, typename Key> class UnorderedMapStorage
{
public:
Expand Down
5 changes: 2 additions & 3 deletions unit_tests/util/query_heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ struct TestData
using TestNodeID = NodeID;
using TestKey = int;
using TestWeight = int;
using storage_types = boost::mpl::list<ArrayStorage<TestNodeID, TestKey>,
MapStorage<TestNodeID, TestKey>,
UnorderedMapStorage<TestNodeID, TestKey>>;
using storage_types =
boost::mpl::list<ArrayStorage<TestNodeID, TestKey>, UnorderedMapStorage<TestNodeID, TestKey>>;

template <unsigned NUM_ELEM> struct RandomDataFixture
{
Expand Down

0 comments on commit c2f877e

Please sign in to comment.