1 /* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_MC_ODPOR_WAKEUP_TREE_ITERATOR_HPP
7 #define SIMGRID_MC_ODPOR_WAKEUP_TREE_ITERATOR_HPP
9 #include "src/mc/explo/odpor/WakeupTree.hpp"
11 #include <boost/iterator/iterator_facade.hpp>
15 namespace simgrid::mc::odpor {
17 struct WakeupTreeIterator
18 : public boost::iterator_facade<WakeupTreeIterator, const WakeupTreeNode*, boost::forward_traversal_tag> {
20 WakeupTreeIterator() = default;
21 explicit WakeupTreeIterator(const WakeupTree& tree);
24 using node_handle = std::list<const WakeupTreeNode*>::iterator;
27 * @brief The current "view" of the iteration in post-order traversal
29 std::stack<node_handle> post_order_iteration;
34 void push_until_left_most_found();
36 // boost::iterator_facade<...> interface to implement
38 bool equal(const WakeupTreeIterator& other) const { return post_order_iteration == other.post_order_iteration; }
39 const WakeupTreeNode*& dereference() const { return *post_order_iteration.top(); }
41 // Allows boost::iterator_facade<...> to function properly
42 friend class boost::iterator_core_access;
45 } // namespace simgrid::mc::odpor