mirror of https://gitee.com/bigwinds/arangodb
Rename lookup() to find()
This commit is contained in:
parent
589a32cda4
commit
b8ef4782ca
|
@ -100,15 +100,15 @@ BOOST_AUTO_TEST_CASE (tst_deque_case) {
|
||||||
|
|
||||||
MyValue const* p;
|
MyValue const* p;
|
||||||
|
|
||||||
p = pq.lookup("a");
|
p = pq.find("a");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 1);
|
BOOST_CHECK_EQUAL(p->_weight, 1);
|
||||||
p = pq.lookup("b");
|
p = pq.find("b");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("c");
|
p = pq.find("c");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("d");
|
p = pq.find("d");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 4);
|
BOOST_CHECK_EQUAL(p->_weight, 4);
|
||||||
p = pq.lookup("abc");
|
p = pq.find("abc");
|
||||||
BOOST_CHECK(p == nullptr);
|
BOOST_CHECK(p == nullptr);
|
||||||
|
|
||||||
std::string k;
|
std::string k;
|
||||||
|
@ -186,15 +186,15 @@ BOOST_AUTO_TEST_CASE (tst_heap_case) {
|
||||||
|
|
||||||
MyValue const* p;
|
MyValue const* p;
|
||||||
|
|
||||||
p = pq.lookup("a");
|
p = pq.find("a");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 4);
|
BOOST_CHECK_EQUAL(p->_weight, 4);
|
||||||
p = pq.lookup("b");
|
p = pq.find("b");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 1);
|
BOOST_CHECK_EQUAL(p->_weight, 1);
|
||||||
p = pq.lookup("c");
|
p = pq.find("c");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("d");
|
p = pq.find("d");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("abc");
|
p = pq.find("abc");
|
||||||
BOOST_CHECK(p == nullptr);
|
BOOST_CHECK(p == nullptr);
|
||||||
|
|
||||||
std::string k;
|
std::string k;
|
||||||
|
@ -274,15 +274,15 @@ BOOST_AUTO_TEST_CASE (tst_deque_case_with_lowering) {
|
||||||
|
|
||||||
MyValue const* p;
|
MyValue const* p;
|
||||||
|
|
||||||
p = pq.lookup("a");
|
p = pq.find("a");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 1);
|
BOOST_CHECK_EQUAL(p->_weight, 1);
|
||||||
p = pq.lookup("b");
|
p = pq.find("b");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("c");
|
p = pq.find("c");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("d");
|
p = pq.find("d");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 1);
|
BOOST_CHECK_EQUAL(p->_weight, 1);
|
||||||
p = pq.lookup("abc");
|
p = pq.find("abc");
|
||||||
BOOST_CHECK(p == nullptr);
|
BOOST_CHECK(p == nullptr);
|
||||||
|
|
||||||
std::string k;
|
std::string k;
|
||||||
|
@ -362,15 +362,15 @@ BOOST_AUTO_TEST_CASE (tst_heap_case_with_lowering) {
|
||||||
|
|
||||||
MyValue const* p;
|
MyValue const* p;
|
||||||
|
|
||||||
p = pq.lookup("a");
|
p = pq.find("a");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 1);
|
BOOST_CHECK_EQUAL(p->_weight, 1);
|
||||||
p = pq.lookup("b");
|
p = pq.find("b");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 2);
|
BOOST_CHECK_EQUAL(p->_weight, 2);
|
||||||
p = pq.lookup("c");
|
p = pq.find("c");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 3);
|
BOOST_CHECK_EQUAL(p->_weight, 3);
|
||||||
p = pq.lookup("d");
|
p = pq.find("d");
|
||||||
BOOST_CHECK_EQUAL(p->_weight, 3);
|
BOOST_CHECK_EQUAL(p->_weight, 3);
|
||||||
p = pq.lookup("abc");
|
p = pq.find("abc");
|
||||||
BOOST_CHECK(p == nullptr);
|
BOOST_CHECK(p == nullptr);
|
||||||
|
|
||||||
std::string k;
|
std::string k;
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Searcher : public Thread {
|
||||||
Traverser::EdgeWeight weight) {
|
Traverser::EdgeWeight weight) {
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(_myInfo._mutex);
|
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:
|
// Not found, so insert it:
|
||||||
if (s == nullptr) {
|
if (s == nullptr) {
|
||||||
|
@ -90,7 +90,7 @@ class Searcher : public Thread {
|
||||||
Traverser::EdgeWeight weight) {
|
Traverser::EdgeWeight weight) {
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(_peerInfo._mutex);
|
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) {
|
if (s == nullptr) {
|
||||||
// Not found, nothing more to do
|
// Not found, nothing more to do
|
||||||
return;
|
return;
|
||||||
|
@ -156,7 +156,7 @@ class Searcher : public Thread {
|
||||||
lookupPeer(v, s._weight);
|
lookupPeer(v, s._weight);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(_myInfo._mutex);
|
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;
|
s2->_done = true;
|
||||||
b = _myInfo._pq.popMinimal(v, s, true);
|
b = _myInfo._pq.popMinimal(v, s, true);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ Traverser::Path* Traverser::shortestPath (VertexId const& start,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Step* s = forward._pq.lookup(_intermediate);
|
Step* s = forward._pq.find(_intermediate);
|
||||||
r_vertices.push_back(_intermediate);
|
r_vertices.push_back(_intermediate);
|
||||||
|
|
||||||
// FORWARD Go path back from intermediate -> start.
|
// FORWARD Go path back from intermediate -> start.
|
||||||
|
@ -209,17 +209,17 @@ Traverser::Path* Traverser::shortestPath (VertexId const& start,
|
||||||
while (s->_predecessor != "") {
|
while (s->_predecessor != "") {
|
||||||
r_edges.push_front(s->_edge);
|
r_edges.push_front(s->_edge);
|
||||||
r_vertices.push_front(s->_predecessor);
|
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.
|
// BACKWARD Go path back from intermediate -> target.
|
||||||
// Insert all vertices and edges at back of vector
|
// Insert all vertices and edges at back of vector
|
||||||
// Also insert the intermediate vertex
|
// Also insert the intermediate vertex
|
||||||
s = backward._pq.lookup(_intermediate);
|
s = backward._pq.find(_intermediate);
|
||||||
while (s->_predecessor != "") {
|
while (s->_predecessor != "") {
|
||||||
r_edges.push_back(s->_edge);
|
r_edges.push_back(s->_edge);
|
||||||
r_vertices.push_back(s->_predecessor);
|
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);
|
return new Path(r_vertices, r_edges, _highscore);
|
||||||
};
|
};
|
||||||
|
|
|
@ -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
|
/// the next modification of the data structure happens (insert or lowerWeight
|
||||||
/// or popMinimal). The weight in the Value type must not be modified other
|
/// or popMinimal). The weight in the Value type must not be modified other
|
||||||
/// than via lowerWeight, otherwise the queue order could be violated.
|
/// 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);
|
auto it = _lookup.find(k);
|
||||||
if (it == _lookup.end()) {
|
if (it == _lookup.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Reference in New Issue