X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/edc5c089fec77e74e39c8887a640fe03226d8a3f..dc6726419e36dd2853c7773e0a8fc177091e79e0:/src/mc/explo/odpor/WakeupTree.hpp diff --git a/src/mc/explo/odpor/WakeupTree.hpp b/src/mc/explo/odpor/WakeupTree.hpp index c6cbf20c32..59b96c3f31 100644 --- a/src/mc/explo/odpor/WakeupTree.hpp +++ b/src/mc/explo/odpor/WakeupTree.hpp @@ -21,7 +21,17 @@ namespace simgrid::mc::odpor { /** * @brief A single node in a wakeup tree * - * Each node in a wakeup tree contains + * Each node in a wakeup tree represents a single step + * taken in an extension of the execution represented + * by the tree within which the node is contained. That is, + * a node in the tree is one step on a "pre-defined" + * path forward for some execution sequence. The partial + * execution that is implicitly represented by the node + * is that formed by taking each step on the (unique) + * path in the tree from the root node to this node. + * Thus, the tree itself contains all of the paths + * that "should be" searched, while each node is + * simply a step on each path. */ class WakeupTreeNode { private: @@ -49,10 +59,10 @@ public: WakeupTreeNode& operator=(const WakeupTreeNode&) = delete; WakeupTreeNode& operator=(WakeupTreeNode&&) = default; - const auto begin() const { return this->children_.begin(); } - const auto end() const { return this->children_.end(); } - const auto rbegin() const { return this->children_.rbegin(); } - const auto rend() const { return this->children_.rend(); } + auto begin() const { return this->children_.begin(); } + auto end() const { return this->children_.end(); } + auto rbegin() const { return this->children_.rbegin(); } + auto rend() const { return this->children_.rend(); } bool is_leaf() const { return children_.empty(); } bool is_root() const { return parent_ == nullptr; } @@ -163,6 +173,17 @@ public: */ bool empty() const { return nodes_.size() == static_cast(1); } + /** + * @brief Returns the number of *non-empty* entries in the tree, viz. the + * number of nodes in the tree that have an action mapped to them + */ + size_t get_num_entries() const { return not empty() ? (nodes_.size() - 1) : static_cast(0); } + + /** + * @brief Returns the number of nodes in the tree, including the root node + */ + size_t get_num_nodes() const { return nodes_.size(); } + /** * @brief Gets the actor of the node that is the "smallest" (with respect * to the tree's "<" relation) single-process node. @@ -179,6 +200,9 @@ public: */ std::optional get_min_single_process_node() const; + /** @brief Describes how a tree insertion was carried out */ + enum class InsertionResult { leaf, interior_node, root }; + /** * @brief Inserts an sequence `seq` of processes into the tree * such that that this tree is a wakeup tree relative to the @@ -203,8 +227,11 @@ public: * * @invariant: It is assumed that this tree is a wakeup tree * with respect to the given execution `E` + * + * @return Whether a sequence equivalent to `seq` is already contained + * as a leaf node in the tree */ - void insert(const Execution& E, const PartialExecution& seq); + InsertionResult insert(const Execution& E, const PartialExecution& seq); }; } // namespace simgrid::mc::odpor