diff --git a/libs/util/include/psemek/util/dfs.hpp b/libs/util/include/psemek/util/dfs.hpp index 5a1613ed..0956704a 100644 --- a/libs/util/include/psemek/util/dfs.hpp +++ b/libs/util/include/psemek/util/dfs.hpp @@ -20,20 +20,39 @@ namespace psemek::util struct cycle_iterator { + using iterator_category = std::forward_iterator_tag; + using value_type = Index; + using reference_type = Index; + using pointer = Index *; + using difference_type = int; + dfs * parent; Index i; Index operator *() const { return i; } + cycle_iterator & operator ++() { i = parent->parent_[i]; return *this; } + cycle_iterator operator ++(int) + { + auto copy = *this; + i = parent->parent_[i]; + return copy; + } + friend bool operator == (cycle_iterator const & i1, cycle_iterator const & i2) { return i1.i == i2.i; } + + friend bool operator != (cycle_iterator const & i1, cycle_iterator const & i2) + { + return i1.i != i2.i; + } }; template