bool Graph::getCycleEdge(int i0, int i1) const { EdgeKey eKey(i0, i1); Edges::const_iterator iter = mEdges.find(eKey); if(iter != mEdges.end()) return iter->second; return false; }
bool Graph::removeEdge(int i0, int i1) { Vertex* v0 = (Vertex*)getVertex(i0); if(!v0) return false; Vertex* v1 = (Vertex*)getVertex(i1); if(!v1) return false; EdgeKey eKey(i0, i1); map<EdgeKey, bool>::iterator iter = mEdges.find(eKey); if(iter != mEdges.end()) { mEdges.erase(iter); v0->remove(v1); v1->remove(v0); return true; } return false; }
bool Graph::insertEdge(int i0, int i1) { Vertex* v0 = (Vertex*)getVertex(i0); if(!v0) return false; Vertex* v1 = (Vertex*)getVertex(i1); if(!v1) return false; EdgeKey eKey(i0, i1); map<EdgeKey, bool>::iterator iter = mEdges.find(eKey); if(iter == mEdges.end()) { mEdges[eKey] = false; v0->insert(v1); v1->insert(v0); return true; } return false; }
void IndexCursor::_prelockRange(const BSONObj &startKey, const BSONObj &endKey) { const bool isSecondary = !_cl->isPKIndex(_idx); // The ydb requires that we only lock ranges such that the left // endpoint is less than or equal to the right endpoint. // Reverse cursors describe the start and end key as the two // keys where they start and end iteration, which is backwards // in the key space (because they iterate in reverse). const BSONObj &leftKey = forward() ? startKey : endKey; const BSONObj &rightKey = forward() ? endKey : startKey; dassert(leftKey.woCompare(rightKey, _ordering) <= 0); storage::Key sKey(leftKey, isSecondary ? &minKey : NULL); storage::Key eKey(rightKey, isSecondary ? &maxKey : NULL); DBT start = sKey.dbt(); DBT end = eKey.dbt(); DBC *cursor = _cursor.dbc(); const int r = cursor->c_set_bounds( cursor, &start, &end, true, 0 ); if ( r != 0 ) { storage::handle_ydb_error(r); } }
void Graph::setCycleEdge(int i0, int i1) { EdgeKey eKey(i0, i1); Edges::iterator iter = mEdges.find(eKey); if(iter != mEdges.end()) iter->second = true; }