#include #include "Graph.hpp" #include "Task.hpp" #include "Uniqueworklist.hpp" std::optional TaskDCP::addChild(TaskDCP* child, Weight_t weight) { std::optional oldEdge = std::nullopt; auto founded_element = std::find_if(childs.begin(), childs.end(), [child](Edge_t element) { return child == element.first; }); if (founded_element != childs.end()) { oldEdge = *founded_element; fastRemove(childs, founded_element); } childs.emplace_back(child, weight); return oldEdge; } std::optional TaskDCP::addParent(TaskDCP* parent, Weight_t weight) { std::optional oldEdge = std::nullopt; auto founded_element = std::find_if(parents.begin(), parents.end(), [parent](Edge_t element) { return parent == element.first; }); if (founded_element != parents.end()) { oldEdge = *founded_element; fastRemove(parents, founded_element); } parents.emplace_back(parent, weight); return oldEdge; } bool TaskDCP::hasDescendent(TaskDCP* child) { UniqueWorkList> worklist; worklist.reserve(32); worklist.push_back(this); while (!worklist.empty()) { TaskDCP* task = worklist.back(); worklist.pop_back(); if (task == child) return true; for (auto c : task->childs) worklist.push_back(c.first); } return false; } // TODO fare qualcosa di sensato int TaskDCP::computeWeight(GraphDCP* graph, CPU cpu) { return orig_weight; }