Skip to content

Commit

Permalink
Implement the add-assign operator for VertexIter (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixueclaire authored May 6, 2023
1 parent b519b74 commit 807f2da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpp/include/gar/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ class VertexIter {
return ret;
}

/** The add-assign operator. */
VertexIter& operator+=(IdType offset) {
cur_offset_ += offset;
return *this;
}

/** The equality operator. */
bool operator==(const VertexIter& rhs) const noexcept {
return cur_offset_ == rhs.cur_offset_;
Expand Down
11 changes: 11 additions & 0 deletions cpp/test/test_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ TEST_CASE("test_vertices_collection") {
<< ", id=" << it_last.property<int64_t>("id").value()
<< ", firstName="
<< it_last.property<std::string>("firstName").value() << std::endl;
auto it_begin = it_last + (1 - count);

auto it = vertices.begin();
it += (count - 1);
REQUIRE(it.id() == it_last.id());
REQUIRE(it.property<int64_t>("id").value() ==
it_last.property<int64_t>("id").value());
it += (1 - count);
REQUIRE(it.id() == it_begin.id());
REQUIRE(it.property<int64_t>("id").value() ==
it_begin.property<int64_t>("id").value());
}

TEST_CASE("test_edges_collection", "[Slow]") {
Expand Down

0 comments on commit 807f2da

Please sign in to comment.