typedef unsigned int uint
This commit is contained in:
parent
3740a274a8
commit
ac1f11e2b3
6 changed files with 40 additions and 43 deletions
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
unsigned int dimension = 0; // = variables.size()
|
uint dimension = 0; // = variables.size()
|
||||||
unsigned int numElements = 0; // = 2 ^ dimension
|
uint numElements = 0; // = 2 ^ dimension
|
||||||
bool KNF = false;
|
bool KNF = false;
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
|
@ -84,8 +84,8 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
// initialize Cells
|
// initialize Cells
|
||||||
vector<Cell*> cells;
|
vector<Cell*> cells;
|
||||||
cells.resize(numElements);
|
cells.resize(numElements);
|
||||||
unsigned int numOnes = 0;
|
uint numOnes = 0;
|
||||||
for (unsigned int i = 0; i < numElements; i++)
|
for (uint i = 0; i < numElements; i++)
|
||||||
{
|
{
|
||||||
cells[i] = new Cell(i, globalPIC);
|
cells[i] = new Cell(i, globalPIC);
|
||||||
printf("Pos %2d: %d\n", i, cells[i]->value);
|
printf("Pos %2d: %d\n", i, cells[i]->value);
|
||||||
|
@ -97,10 +97,10 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
// find hazards
|
// find hazards
|
||||||
if (numOnes > numElements / 2) // we have more 1 than 0 --> checkerboard --> 50% of cells are checked
|
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";
|
cout << "\nSchachbrettmuster\n";
|
||||||
unsigned int grayI = i ^ (i/2); // transform to gray code
|
uint grayI = i ^ (i/2); // transform to gray code
|
||||||
vector<Cell*> hazardousNeighbors = cells[grayI]->GetHazards();
|
vector<Cell*> hazardousNeighbors = cells[grayI]->GetHazards();
|
||||||
|
|
||||||
if (hazardousNeighbors.size() == 0) // we found no hazard
|
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
|
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";
|
cout << "\nÜberspringe Nullen\n";
|
||||||
if (!cells[i]->value)
|
if (!cells[i]->value)
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool PrimImplikant::valueAt(unsigned int pos) {
|
bool PrimImplikant::valueAt(uint pos) {
|
||||||
for (vector<unsigned int>::iterator i = implikanten.begin(); i < implikanten.end(); ++i)
|
for (vector<uint>::iterator i = implikanten.begin(); i < implikanten.end(); ++i)
|
||||||
if (*i == pos)
|
if (*i == pos)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ bool PrimImplikant::valueAt(unsigned int pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimImplikant::parser(string input) { // Analyser
|
void PrimImplikant::parser(string input) { // Analyser
|
||||||
unsigned int implikant = 0;
|
uint implikant = 0;
|
||||||
string text0 = "";
|
string text0 = "";
|
||||||
string text1 = "";
|
string text1 = "";
|
||||||
for (unsigned int i = 0; i < input.size(); i++)
|
for (uint i = 0; i < input.size(); i++)
|
||||||
{
|
{
|
||||||
char c = input[i];
|
char c = input[i];
|
||||||
if (c == 'x' || c == 'X')
|
if (c == 'x' || c == 'X')
|
||||||
|
@ -36,7 +36,7 @@ void PrimImplikant::parser(string input) { // Analyser
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
implikant <<= 1; // *2
|
implikant <<= 1; // *2
|
||||||
implikant += (unsigned int)c - (unsigned int)'0';
|
implikant += (uint)c - (uint)'0';
|
||||||
}
|
}
|
||||||
implikanten.push_back(implikant);
|
implikanten.push_back(implikant);
|
||||||
}
|
}
|
|
@ -16,20 +16,20 @@ public:
|
||||||
name = input;
|
name = input;
|
||||||
parser(input);
|
parser(input);
|
||||||
}
|
}
|
||||||
PrimImplikant(unsigned int input)
|
PrimImplikant(uint input)
|
||||||
{
|
{
|
||||||
char nameC[sizeof(unsigned int)*8+1];
|
char nameC[sizeof(uint)*8+1];
|
||||||
_itoa_s(input, nameC, sizeof(unsigned int)*8+1, 10);
|
_itoa_s(input, nameC, sizeof(uint)*8+1, 10);
|
||||||
name = nameC;
|
name = nameC;
|
||||||
|
|
||||||
implikanten.push_back(input);
|
implikanten.push_back(input);
|
||||||
}
|
}
|
||||||
PrimImplikant(unsigned int input1, unsigned int input2)
|
PrimImplikant(uint input1, uint input2)
|
||||||
{
|
{
|
||||||
char nameC[sizeof(unsigned int)*8+1];
|
char nameC[sizeof(uint)*8+1];
|
||||||
_itoa_s(input1, nameC, sizeof(unsigned int)*8+1, 10);
|
_itoa_s(input1, nameC, sizeof(uint)*8+1, 10);
|
||||||
name = nameC;
|
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(" & ");
|
||||||
name.append(nameC);
|
name.append(nameC);
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ public:
|
||||||
implikanten.push_back(input2);
|
implikanten.push_back(input2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrimImplikant::valueAt(unsigned int position);
|
bool PrimImplikant::valueAt(uint position);
|
||||||
void PrimImplikant::parser(string input);
|
void PrimImplikant::parser(string input);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<unsigned int> implikanten;
|
vector<uint> implikanten;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -15,18 +15,18 @@ void PrimImplikantCollection::add(string input)
|
||||||
PrimImplikant* PI = new PrimImplikant(input);
|
PrimImplikant* PI = new PrimImplikant(input);
|
||||||
PIVector.push_back(PI);
|
PIVector.push_back(PI);
|
||||||
}
|
}
|
||||||
void PrimImplikantCollection::add(unsigned int input)
|
void PrimImplikantCollection::add(uint input)
|
||||||
{
|
{
|
||||||
PrimImplikant* PI = new PrimImplikant(input);
|
PrimImplikant* PI = new PrimImplikant(input);
|
||||||
PIVector.push_back(PI);
|
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);
|
PrimImplikant* PI = new PrimImplikant(input1, input2);
|
||||||
PIVector.push_back(PI);
|
PIVector.push_back(PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrimImplikantCollection::valueAt(unsigned int position)
|
bool PrimImplikantCollection::valueAt(uint position)
|
||||||
{
|
{
|
||||||
for (vector<PrimImplikant*>::iterator i = PIVector.begin(); i < PIVector.end(); i++)
|
for (vector<PrimImplikant*>::iterator i = PIVector.begin(); i < PIVector.end(); i++)
|
||||||
if ((*i)->valueAt(position))
|
if ((*i)->valueAt(position))
|
||||||
|
@ -34,7 +34,7 @@ bool PrimImplikantCollection::valueAt(unsigned int position)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(unsigned int position)
|
PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(uint position)
|
||||||
{
|
{
|
||||||
PrimImplikantCollection pic;
|
PrimImplikantCollection pic;
|
||||||
for (vector<PrimImplikant*>::iterator i = PIVector.begin(); i < PIVector.end(); i++)
|
for (vector<PrimImplikant*>::iterator i = PIVector.begin(); i < PIVector.end(); i++)
|
||||||
|
@ -43,7 +43,7 @@ PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(unsigned int
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PrimImplikantCollection::size()
|
uint PrimImplikantCollection::size()
|
||||||
{
|
{
|
||||||
return this->PIVector.size();
|
return this->PIVector.size();
|
||||||
}
|
}
|
||||||
|
@ -58,17 +58,14 @@ PrimImplikant* PrimImplikantCollection::front()
|
||||||
return this->PIVector.front();
|
return this->PIVector.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimImplikant* PrimImplikantCollection::at(unsigned int const &index)
|
PrimImplikant* PrimImplikantCollection::at(uint &index)
|
||||||
{
|
{
|
||||||
return this->PIVector.at(index);
|
return this->PIVector.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PrimImplikant* PrimImplikantCollection::operator[](unsigned int const &index){
|
PrimImplikant* PrimImplikantCollection::operator[](uint &index){
|
||||||
if (index <= PIVector.size()){
|
if (index < PIVector.size())
|
||||||
|
|
||||||
return this->PIVector.at(index);
|
return this->PIVector.at(index);
|
||||||
}
|
|
||||||
|
|
||||||
cerr << "Fehler!!!! PIVector.size()=" << PIVector.size() << endl;
|
|
||||||
return 0;
|
return 0;
|
||||||
}*/
|
}
|
|
@ -12,22 +12,21 @@ class PrimImplikantCollection{
|
||||||
public:
|
public:
|
||||||
void add(PrimImplikant* &PI);
|
void add(PrimImplikant* &PI);
|
||||||
void add(string input);
|
void add(string input);
|
||||||
void add(unsigned int input);
|
void add(uint input);
|
||||||
void add(unsigned int input1, unsigned int input2);
|
void add(uint input1, uint input2);
|
||||||
|
|
||||||
bool valueAt(unsigned int position);
|
bool valueAt(uint position);
|
||||||
PrimImplikantCollection primImplikantenAt(unsigned int position);
|
PrimImplikantCollection primImplikantenAt(uint position);
|
||||||
|
|
||||||
unsigned int size();
|
uint size();
|
||||||
PrimImplikant* back();
|
PrimImplikant* back();
|
||||||
PrimImplikant* front();
|
PrimImplikant* front();
|
||||||
PrimImplikant* at(unsigned int const &index);
|
PrimImplikant* at(uint &index);
|
||||||
PrimImplikant* operator[](unsigned int const &index);
|
PrimImplikant* operator[](uint &index);
|
||||||
const PrimImplikant* operator[](unsigned int const &index) const;
|
|
||||||
|
|
||||||
~PrimImplikantCollection() // destructor
|
~PrimImplikantCollection() // destructor
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->size(); i++)
|
for (uint i = 0; i < this->size(); i++)
|
||||||
delete this->at(i);
|
delete this->at(i);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
|
typedef unsigned short ushort;
|
||||||
|
typedef unsigned int uint;
|
||||||
|
|
||||||
// TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen.
|
// TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen.
|
Loading…
Reference in a new issue