typedef unsigned int uint

This commit is contained in:
Jonny007-MKD 2013-11-21 20:56:39 +01:00
parent 3740a274a8
commit ac1f11e2b3
6 changed files with 40 additions and 43 deletions

View File

@ -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<Cell*> 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<Cell*> 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)

View File

@ -5,8 +5,8 @@
using namespace std;
bool PrimImplikant::valueAt(unsigned int pos) {
for (vector<unsigned int>::iterator i = implikanten.begin(); i < implikanten.end(); ++i)
bool PrimImplikant::valueAt(uint pos) {
for (vector<uint>::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);
}

View File

@ -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<unsigned int> implikanten;
vector<uint> implikanten;
};
#endif

View File

@ -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<PrimImplikant*>::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<PrimImplikant*>::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;
}*/
}

View File

@ -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:

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <tchar.h>
typedef unsigned short ushort;
typedef unsigned int uint;
// TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen.