|
|
|
@ -32,18 +32,18 @@ Personne::~Personne() {
|
|
|
|
|
|
|
|
|
|
bool Personne::peutCommuniquerA(const Personne &p) const {
|
|
|
|
|
unordered_set<const Personne*> visited;
|
|
|
|
|
queue<const Personne*> pile;
|
|
|
|
|
pile.push(this);
|
|
|
|
|
while (!pile.empty()) {
|
|
|
|
|
const Personne* front = pile.front();
|
|
|
|
|
pile.pop();
|
|
|
|
|
queue<const Personne*> file;
|
|
|
|
|
file.push(this);
|
|
|
|
|
while (!file.empty()) {
|
|
|
|
|
const Personne* front = file.front();
|
|
|
|
|
file.pop();
|
|
|
|
|
for (const Personne* perso : front->contacts->getValue()) {
|
|
|
|
|
if (perso == &p) {
|
|
|
|
|
cout << this->prenom << " peut communiquer avec " << p.getPrenom() << "\n";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (visited.find(perso) == visited.end()) {
|
|
|
|
|
pile.push(perso);
|
|
|
|
|
file.push(perso);
|
|
|
|
|
visited.insert(perso);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|