Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mpl::list is a fancy tuple, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems not exactly... Tuple is runtime type, but mpl is all about meta programming, i.e. it is list of types. It seems MPL is required to use BOOST_FIXTURE_TEST_CASE_TEMPLATE we are using below.
I couldn't find official docs for this macro, but at least this SO example uses it(and it is not obvious how could I substitute it to smth else):
https://stackoverflow.com/questions/22065225/execute-one-test-case-several-times-with-different-fixture-each-time

boost::mpl::list<ArrayStorage<TestNodeID, TestKey>, UnorderedMapStorage<TestNodeID, TestKey>>;

template <unsigned NUM_ELEM> struct RandomDataFixture
{
Expand Down