#include "stdafx.h" #include #include #include "PrimImplikantCollection.h" #include "Cell.h" using namespace std; extern uint dimension; void Cell::refresh(PrimImplikantCollection* &globalPIC) { this->primImplikanten = globalPIC->primImplikantenAt(index); } vector* Cell::getNeighbors(vector &allCells) { vector* neighbors = new vector(); uint j = 1; for (unsigned char i = 0; i < dimension; i++) { neighbors->push_back(allCells[this->index ^ j]); j <<= 1; } return neighbors; } vector* Cell::getHazards(vector &allCells) { vector* hazardous = new vector(); vector* neighbors = this->getNeighbors(allCells); for (vector::iterator neighbor = neighbors->begin(); neighbor < neighbors->end(); neighbor++) { if ((*neighbor)->value == false) continue; if ((*neighbor)->hasOneOfThose(this->primImplikanten) == false) hazardous->push_back(*neighbor); } delete neighbors; return hazardous; } bool Cell::hasOneOfThose(PrimImplikantCollection &foreignPic) { for (uint i = 0; i < foreignPic.size(); i++) if (this->primImplikanten.contains(foreignPic[i])) return true; return false; }