diff --git a/Hazard/Hazard/Hazard.cpp b/Hazard/Hazard/Hazard.cpp index 5da206e..69af299 100644 --- a/Hazard/Hazard/Hazard.cpp +++ b/Hazard/Hazard/Hazard.cpp @@ -12,8 +12,8 @@ using namespace std; -unsigned int dimension = 0; // = variables.size() -unsigned int numElements = 0; // = 2 ^ dimension +uint dimension = 0; // = variables.size() +uint numElements = 0; // = 2 ^ dimension bool KNF = false; int _tmain(int argc, _TCHAR* argv[]) @@ -84,8 +84,8 @@ int _tmain(int argc, _TCHAR* argv[]) // initialize Cells vector cells; cells.resize(numElements); - unsigned int numOnes = 0; - for (unsigned int i = 0; i < numElements; i++) + uint numOnes = 0; + for (uint i = 0; i < numElements; i++) { cells[i] = new Cell(i, globalPIC); printf("Pos %2d: %d\n", i, cells[i]->value); @@ -97,10 +97,10 @@ int _tmain(int argc, _TCHAR* argv[]) // find hazards if (numOnes > numElements / 2) // we have more 1 than 0 --> checkerboard --> 50% of cells are checked { - for (unsigned int i = 0; i < numElements; i++) + for (uint i = 0; i < numElements; i++) { cout << "\nSchachbrettmuster\n"; - unsigned int grayI = i ^ (i/2); // transform to gray code + uint grayI = i ^ (i/2); // transform to gray code vector hazardousNeighbors = cells[grayI]->GetHazards(); if (hazardousNeighbors.size() == 0) // we found no hazard @@ -115,7 +115,7 @@ int _tmain(int argc, _TCHAR* argv[]) } else // less 1 than 0 --> only check every 1 --> less than 50% (numOnes/numElements) of cells are checked { - for (unsigned int i = 0; i < numElements; i++) + for (uint i = 0; i < numElements; i++) { cout << "\nÜberspringe Nullen\n"; if (!cells[i]->value) diff --git a/Hazard/Hazard/PrimImplikant.cpp b/Hazard/Hazard/PrimImplikant.cpp index 252e484..4036cc5 100644 --- a/Hazard/Hazard/PrimImplikant.cpp +++ b/Hazard/Hazard/PrimImplikant.cpp @@ -5,8 +5,8 @@ using namespace std; -bool PrimImplikant::valueAt(unsigned int pos) { - for (vector::iterator i = implikanten.begin(); i < implikanten.end(); ++i) +bool PrimImplikant::valueAt(uint pos) { + for (vector::iterator i = implikanten.begin(); i < implikanten.end(); ++i) if (*i == pos) return true; @@ -14,10 +14,10 @@ bool PrimImplikant::valueAt(unsigned int pos) { } void PrimImplikant::parser(string input) { // Analyser - unsigned int implikant = 0; + uint implikant = 0; string text0 = ""; string text1 = ""; - for (unsigned int i = 0; i < input.size(); i++) + for (uint i = 0; i < input.size(); i++) { char c = input[i]; if (c == 'x' || c == 'X') @@ -36,7 +36,7 @@ void PrimImplikant::parser(string input) { // Analyser return; } implikant <<= 1; // *2 - implikant += (unsigned int)c - (unsigned int)'0'; + implikant += (uint)c - (uint)'0'; } implikanten.push_back(implikant); } \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikant.h b/Hazard/Hazard/PrimImplikant.h index ee26dc4..e9f2ad8 100644 --- a/Hazard/Hazard/PrimImplikant.h +++ b/Hazard/Hazard/PrimImplikant.h @@ -16,20 +16,20 @@ public: name = input; parser(input); } - PrimImplikant(unsigned int input) + PrimImplikant(uint input) { - char nameC[sizeof(unsigned int)*8+1]; - _itoa_s(input, nameC, sizeof(unsigned int)*8+1, 10); + char nameC[sizeof(uint)*8+1]; + _itoa_s(input, nameC, sizeof(uint)*8+1, 10); name = nameC; implikanten.push_back(input); } - PrimImplikant(unsigned int input1, unsigned int input2) + PrimImplikant(uint input1, uint input2) { - char nameC[sizeof(unsigned int)*8+1]; - _itoa_s(input1, nameC, sizeof(unsigned int)*8+1, 10); + char nameC[sizeof(uint)*8+1]; + _itoa_s(input1, nameC, sizeof(uint)*8+1, 10); name = nameC; - _itoa_s(input2, nameC, sizeof(unsigned int)*8+1, 10); + _itoa_s(input2, nameC, sizeof(uint)*8+1, 10); name.append(" & "); name.append(nameC); @@ -37,11 +37,11 @@ public: implikanten.push_back(input2); } - bool PrimImplikant::valueAt(unsigned int position); + bool PrimImplikant::valueAt(uint position); void PrimImplikant::parser(string input); private: - vector implikanten; + vector implikanten; }; #endif \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index 0bd57ba..c1d3e4d 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -15,18 +15,18 @@ void PrimImplikantCollection::add(string input) PrimImplikant* PI = new PrimImplikant(input); PIVector.push_back(PI); } -void PrimImplikantCollection::add(unsigned int input) +void PrimImplikantCollection::add(uint input) { PrimImplikant* PI = new PrimImplikant(input); PIVector.push_back(PI); } -void PrimImplikantCollection::add(unsigned int input1, unsigned int input2) +void PrimImplikantCollection::add(uint input1, uint input2) { PrimImplikant* PI = new PrimImplikant(input1, input2); PIVector.push_back(PI); } -bool PrimImplikantCollection::valueAt(unsigned int position) +bool PrimImplikantCollection::valueAt(uint position) { for (vector::iterator i = PIVector.begin(); i < PIVector.end(); i++) if ((*i)->valueAt(position)) @@ -34,7 +34,7 @@ bool PrimImplikantCollection::valueAt(unsigned int position) return false; } -PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(unsigned int position) +PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(uint position) { PrimImplikantCollection pic; for (vector::iterator i = PIVector.begin(); i < PIVector.end(); i++) @@ -43,7 +43,7 @@ PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(unsigned int return pic; } -unsigned int PrimImplikantCollection::size() +uint PrimImplikantCollection::size() { return this->PIVector.size(); } @@ -58,17 +58,14 @@ PrimImplikant* PrimImplikantCollection::front() return this->PIVector.front(); } -PrimImplikant* PrimImplikantCollection::at(unsigned int const &index) +PrimImplikant* PrimImplikantCollection::at(uint &index) { return this->PIVector.at(index); } -/*PrimImplikant* PrimImplikantCollection::operator[](unsigned int const &index){ - if (index <= PIVector.size()){ - +PrimImplikant* PrimImplikantCollection::operator[](uint &index){ + if (index < PIVector.size()) return this->PIVector.at(index); - } - cerr << "Fehler!!!! PIVector.size()=" << PIVector.size() << endl; return 0; -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index 0b4c474..b1f9733 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -12,22 +12,21 @@ class PrimImplikantCollection{ public: void add(PrimImplikant* &PI); void add(string input); - void add(unsigned int input); - void add(unsigned int input1, unsigned int input2); + void add(uint input); + void add(uint input1, uint input2); - bool valueAt(unsigned int position); - PrimImplikantCollection primImplikantenAt(unsigned int position); + bool valueAt(uint position); + PrimImplikantCollection primImplikantenAt(uint position); - unsigned int size(); + uint size(); PrimImplikant* back(); PrimImplikant* front(); - PrimImplikant* at(unsigned int const &index); - PrimImplikant* operator[](unsigned int const &index); - const PrimImplikant* operator[](unsigned int const &index) const; + PrimImplikant* at(uint &index); + PrimImplikant* operator[](uint &index); ~PrimImplikantCollection() // destructor { - for (unsigned int i = 0; i < this->size(); i++) + for (uint i = 0; i < this->size(); i++) delete this->at(i); } private: diff --git a/Hazard/Hazard/stdafx.h b/Hazard/Hazard/stdafx.h index 5f7e996..0f95368 100644 --- a/Hazard/Hazard/stdafx.h +++ b/Hazard/Hazard/stdafx.h @@ -10,6 +10,7 @@ #include #include - +typedef unsigned short ushort; +typedef unsigned int uint; // TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen. \ No newline at end of file