X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/623108a0b5b82da1c8d27a6b4c897961d352b8de..d9c66df6160daf502cdc849b68e9882529a4353d:/src/mc/explo/odpor/WakeupTreeIterator.hpp diff --git a/src/mc/explo/odpor/WakeupTreeIterator.hpp b/src/mc/explo/odpor/WakeupTreeIterator.hpp index 2aae9b5107..0ccc6bc0ea 100644 --- a/src/mc/explo/odpor/WakeupTreeIterator.hpp +++ b/src/mc/explo/odpor/WakeupTreeIterator.hpp @@ -6,7 +6,7 @@ #ifndef SIMGRID_MC_ODPOR_WAKEUP_TREE_ITERATOR_HPP #define SIMGRID_MC_ODPOR_WAKEUP_TREE_ITERATOR_HPP -#include "src/mc/explo/odpor/WakeupTree.hpp" +#include "src/mc/explo/odpor/odpor_forward.hpp" #include #include @@ -14,14 +14,37 @@ namespace simgrid::mc::odpor { -struct WakeupTreeIterator - : public boost::iterator_facade { +/** + * @brief A forward-iterator that performs a postorder traversal + * of the nodes of a WakeupTree + * + * Inserting a sequence `w` into a wakeup tree `B` with respect to + * some execution `E` requires determining the "<-minimal" node `N` + * with sequence `v` in the tree such that `v ~_[E] w`. The "<" relation + * over a wakeup tree orders its nodes by first recursively ordering all + * children of a node `N` followed by the node `N` itself, viz. a postorder. + * This iterator provides such a postorder traversal over the nodes in the + * wakeup tree. + */ +class WakeupTreeIterator + : public boost::iterator_facade { public: WakeupTreeIterator() = default; explicit WakeupTreeIterator(const WakeupTree& tree); private: - using node_handle = std::list::iterator; + using node_handle = std::list::iterator; + + /** + * @brief A list which is used to "store" the root node of the traversed + * wakeup tree + * + * The root node is, by definition, not the child of any other node. This + * means that the root node also is contained in any list into which the + * iterator can generate a pointer (iterator). This list takes the role + * of allowing the iterator to treat the root node like any other. + */ + std::list root_list; /** * @brief The current "view" of the iteration in post-order traversal @@ -29,14 +52,16 @@ private: std::stack post_order_iteration; /** - * + * @brief Search the wakeup tree until a leaf node appears at the front + * of the iteration, pushing all children towards the top of the stack + * as the search progresses */ void push_until_left_most_found(); // boost::iterator_facade<...> interface to implement void increment(); bool equal(const WakeupTreeIterator& other) const { return post_order_iteration == other.post_order_iteration; } - const WakeupTreeNode*& dereference() const { return *post_order_iteration.top(); } + WakeupTreeNode*& dereference() const { return *post_order_iteration.top(); } // Allows boost::iterator_facade<...> to function properly friend class boost::iterator_core_access;