This repository has been archived on 2023-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
GestionProjet/src/Projet.cpp

58 lines
1.3 KiB
C++
Raw Normal View History

2023-10-19 23:05:11 +02:00
#include "../includes/Projet.hpp"
2023-10-26 19:08:00 +02:00
Projet::Projet() {}
2023-10-19 23:05:11 +02:00
2023-10-27 18:01:17 +02:00
Projet::Projet(VecTaches t) : taches(t) {}
2023-10-19 23:05:11 +02:00
Projet::~Projet() {}
Projet::Projet(const Projet &) {}
const Projet &Projet::operator=(const Projet &src) {
if (this == &src) {
return *this;
}
return *this;
}
2023-10-24 16:47:59 +02:00
2023-10-27 18:01:17 +02:00
std::pair<int, int> Projet::pick_two_random_tasks() {
2023-10-24 16:47:59 +02:00
int size = this->taches.size();
int rand1 = rand() % size;
int rand2 = rand() % size;
2023-10-27 18:01:17 +02:00
if (this->taches[rand1].first->depends_from(*this->taches[rand2].first))
pick_two_random_tasks();
// Heritage de tache ?
int id1 = this->taches[rand1].first->unique_id;
int id2 = this->taches[rand2].first->unique_id;
2023-10-24 16:47:59 +02:00
return std::make_pair(id1, id2);
}
2023-10-27 18:01:17 +02:00
// Comment acceder à unique_id ici ?
Tache *Projet::contains(int id) {
for (auto t : this->taches) {
if (id == t.first->unique_id) {
return t.first;
}
}
2023-10-24 16:47:59 +02:00
return nullptr;
}
2023-10-27 18:01:17 +02:00
// Comment acceder à taches ici ?
std::ostream &operator<<(std::ostream &out, const Projet &data) {
for (auto t : data.taches) {
out << t.first << " is " << std::boolalpha << t.second;
}
2023-10-24 16:47:59 +02:00
2023-10-27 18:01:17 +02:00
return out;
2023-10-24 16:47:59 +02:00
}
2023-10-26 19:08:00 +02:00
2023-10-27 18:01:17 +02:00
const Projet::VecTaches Projet::topologicalSort() {
// Recupere le calcul fait par PP_postfixe et construit son tri
// PP_postfixe(this->taches);
return VecTaches(); /* TODO */
}