1
0
Fork 0

Rename lookup() to find()

This commit is contained in:
Max Neunhoeffer 2015-04-24 08:59:51 -07:00
parent 589a32cda4
commit b8ef4782ca
3 changed files with 29 additions and 29 deletions

View File

@ -100,15 +100,15 @@ BOOST_AUTO_TEST_CASE (tst_deque_case) {
MyValue const* p;
p = pq.lookup("a");
p = pq.find("a");
BOOST_CHECK_EQUAL(p->_weight, 1);
p = pq.lookup("b");
p = pq.find("b");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("c");
p = pq.find("c");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("d");
p = pq.find("d");
BOOST_CHECK_EQUAL(p->_weight, 4);
p = pq.lookup("abc");
p = pq.find("abc");
BOOST_CHECK(p == nullptr);
std::string k;
@ -186,15 +186,15 @@ BOOST_AUTO_TEST_CASE (tst_heap_case) {
MyValue const* p;
p = pq.lookup("a");
p = pq.find("a");
BOOST_CHECK_EQUAL(p->_weight, 4);
p = pq.lookup("b");
p = pq.find("b");
BOOST_CHECK_EQUAL(p->_weight, 1);
p = pq.lookup("c");
p = pq.find("c");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("d");
p = pq.find("d");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("abc");
p = pq.find("abc");
BOOST_CHECK(p == nullptr);
std::string k;
@ -274,15 +274,15 @@ BOOST_AUTO_TEST_CASE (tst_deque_case_with_lowering) {
MyValue const* p;
p = pq.lookup("a");
p = pq.find("a");
BOOST_CHECK_EQUAL(p->_weight, 1);
p = pq.lookup("b");
p = pq.find("b");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("c");
p = pq.find("c");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("d");
p = pq.find("d");
BOOST_CHECK_EQUAL(p->_weight, 1);
p = pq.lookup("abc");
p = pq.find("abc");
BOOST_CHECK(p == nullptr);
std::string k;
@ -362,15 +362,15 @@ BOOST_AUTO_TEST_CASE (tst_heap_case_with_lowering) {
MyValue const* p;
p = pq.lookup("a");
p = pq.find("a");
BOOST_CHECK_EQUAL(p->_weight, 1);
p = pq.lookup("b");
p = pq.find("b");
BOOST_CHECK_EQUAL(p->_weight, 2);
p = pq.lookup("c");
p = pq.find("c");
BOOST_CHECK_EQUAL(p->_weight, 3);
p = pq.lookup("d");
p = pq.find("d");
BOOST_CHECK_EQUAL(p->_weight, 3);
p = pq.lookup("abc");
p = pq.find("abc");
BOOST_CHECK(p == nullptr);
std::string k;

View File

@ -65,7 +65,7 @@ class Searcher : public Thread {
Traverser::EdgeWeight weight) {
std::lock_guard<std::mutex> guard(_myInfo._mutex);
Traverser::Step* s = _myInfo._pq.lookup(neighbor);
Traverser::Step* s = _myInfo._pq.find(neighbor);
// Not found, so insert it:
if (s == nullptr) {
@ -90,7 +90,7 @@ class Searcher : public Thread {
Traverser::EdgeWeight weight) {
std::lock_guard<std::mutex> guard(_peerInfo._mutex);
Traverser::Step* s = _peerInfo._pq.lookup(vertex);
Traverser::Step* s = _peerInfo._pq.find(vertex);
if (s == nullptr) {
// Not found, nothing more to do
return;
@ -156,7 +156,7 @@ class Searcher : public Thread {
lookupPeer(v, s._weight);
std::lock_guard<std::mutex> guard(_myInfo._mutex);
Traverser::Step* s2 = _myInfo._pq.lookup(v);
Traverser::Step* s2 = _myInfo._pq.find(v);
s2->_done = true;
b = _myInfo._pq.popMinimal(v, s, true);
}
@ -200,7 +200,7 @@ Traverser::Path* Traverser::shortestPath (VertexId const& start,
return nullptr;
}
Step* s = forward._pq.lookup(_intermediate);
Step* s = forward._pq.find(_intermediate);
r_vertices.push_back(_intermediate);
// FORWARD Go path back from intermediate -> start.
@ -209,17 +209,17 @@ Traverser::Path* Traverser::shortestPath (VertexId const& start,
while (s->_predecessor != "") {
r_edges.push_front(s->_edge);
r_vertices.push_front(s->_predecessor);
s = forward._pq.lookup(s->_predecessor);
s = forward._pq.find(s->_predecessor);
}
// BACKWARD Go path back from intermediate -> target.
// Insert all vertices and edges at back of vector
// Also insert the intermediate vertex
s = backward._pq.lookup(_intermediate);
s = backward._pq.find(_intermediate);
while (s->_predecessor != "") {
r_edges.push_back(s->_edge);
r_vertices.push_back(s->_predecessor);
s = backward._pq.lookup(s->_predecessor);
s = backward._pq.find(s->_predecessor);
}
return new Path(r_vertices, r_edges, _highscore);
};

View File

@ -156,13 +156,13 @@ namespace triagens {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief lookup, note that the resulting pointer is only valid until the
/// @brief find, note that the resulting pointer is only valid until the
/// the next modification of the data structure happens (insert or lowerWeight
/// or popMinimal). The weight in the Value type must not be modified other
/// than via lowerWeight, otherwise the queue order could be violated.
////////////////////////////////////////////////////////////////////////////////
Value* lookup (Key const& k) {
Value* find (Key const& k) {
auto it = _lookup.find(k);
if (it == _lookup.end()) {
return nullptr;