Changed int to unsigned int where applicable
Für Indizes und solche Sachen brauchen wir meistens keine Vorzeichen. Hiermit können wir doppelt so viele (65k statt 32k) PrimImplikanten verwalten =)
This commit is contained in:
parent
5608f2b400
commit
7da5e0ff86
5 changed files with 40 additions and 23 deletions
|
@ -54,7 +54,7 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector<string>* &variables)
|
||||||
{
|
{
|
||||||
bool KNFset = false;
|
bool KNFset = false;
|
||||||
int tok;
|
int tok;
|
||||||
if(prflag)fprintf(IP_List,"%5d ",(int)IP_LineNumber);
|
if(prflag)fprintf(IP_List,"%5d ", IP_LineNumber);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go parse things!
|
* Go parse things!
|
||||||
|
@ -96,7 +96,7 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector<string>* &variables)
|
||||||
pic->add(yylval.s.c_str());
|
pic->add(yylval.s.c_str());
|
||||||
break;
|
break;
|
||||||
case INTEGER1:
|
case INTEGER1:
|
||||||
printf("Term Key %d\n",yylval.i);
|
printf("Term Key %d\n", (unsigned int)yylval.i);
|
||||||
pic->add(yylval.i);
|
pic->add(yylval.i);
|
||||||
break;
|
break;
|
||||||
case (int)'>':
|
case (int)'>':
|
||||||
|
|
|
@ -5,17 +5,16 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool PrimImplikant::valueAt(int pos) {
|
bool PrimImplikant::valueAt(unsigned int pos) {
|
||||||
for (vector<int>::iterator i = implikanten.begin(); i < implikanten.end(); ++i)
|
for (vector<unsigned int>::iterator i = implikanten.begin(); i < implikanten.end(); ++i)
|
||||||
{
|
|
||||||
if (*i == pos)
|
if (*i == pos)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimImplikant::parser(string input) { // Analyser
|
void PrimImplikant::parser(string input) { // Analyser
|
||||||
int implikant = 0;
|
unsigned int implikant = 0;
|
||||||
string text0 = "";
|
string text0 = "";
|
||||||
string text1 = "";
|
string text1 = "";
|
||||||
for (unsigned int i = 0; i < input.size(); i++)
|
for (unsigned int i = 0; i < input.size(); i++)
|
||||||
|
@ -37,7 +36,7 @@ void PrimImplikant::parser(string input) { // Analyser
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
implikant <<= 1; // *2
|
implikant <<= 1; // *2
|
||||||
implikant += (int)c - (int)'0';
|
implikant += (unsigned int)c - (unsigned int)'0';
|
||||||
}
|
}
|
||||||
implikanten.push_back(implikant);
|
implikanten.push_back(implikant);
|
||||||
}
|
}
|
|
@ -16,20 +16,32 @@ public:
|
||||||
name = input;
|
name = input;
|
||||||
parser(input);
|
parser(input);
|
||||||
}
|
}
|
||||||
PrimImplikant(int input)
|
PrimImplikant(unsigned int input)
|
||||||
{
|
{
|
||||||
char nameC[sizeof(int)*8+1];
|
char nameC[sizeof(unsigned int)*8+1];
|
||||||
_itoa_s(input, nameC, sizeof(int)*8+1, 10);
|
_itoa_s(input, nameC, sizeof(unsigned int)*8+1, 10);
|
||||||
name = nameC;
|
name = nameC;
|
||||||
|
|
||||||
implikanten.push_back(input);
|
implikanten.push_back(input);
|
||||||
}
|
}
|
||||||
|
PrimImplikant(unsigned int input1, unsigned int input2)
|
||||||
|
{
|
||||||
|
char nameC[sizeof(unsigned int)*8+1];
|
||||||
|
_itoa_s(input1, nameC, sizeof(unsigned int)*8+1, 10);
|
||||||
|
name = nameC;
|
||||||
|
_itoa_s(input2, nameC, sizeof(unsigned int)*8+1, 10);
|
||||||
|
name.append(" & ");
|
||||||
|
name.append(nameC);
|
||||||
|
|
||||||
bool PrimImplikant::valueAt(int position);
|
implikanten.push_back(input1);
|
||||||
|
implikanten.push_back(input2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrimImplikant::valueAt(unsigned int position);
|
||||||
void PrimImplikant::parser(string input);
|
void PrimImplikant::parser(string input);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<int> implikanten;
|
vector<unsigned int> implikanten;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -14,13 +14,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(int input)
|
void PrimImplikantCollection::add(unsigned int 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)
|
||||||
|
{
|
||||||
|
PrimImplikant* PI = new PrimImplikant(input1, input2);
|
||||||
|
PIVector.push_back(PI);
|
||||||
|
}
|
||||||
|
|
||||||
bool PrimImplikantCollection::valueAt(int position)
|
bool PrimImplikantCollection::valueAt(unsigned int 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))
|
||||||
|
@ -28,7 +33,7 @@ bool PrimImplikantCollection::valueAt(int position)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(int position)
|
PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(unsigned int 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++)
|
||||||
|
@ -52,7 +57,7 @@ PrimImplikant* PrimImplikantCollection::front()
|
||||||
return this->PIVector.front();
|
return this->PIVector.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimImplikant* PrimImplikantCollection::at(int const &index)
|
PrimImplikant* PrimImplikantCollection::at(unsigned int const &index)
|
||||||
{
|
{
|
||||||
return this->PIVector.at(index);
|
return this->PIVector.at(index);
|
||||||
}
|
}
|
|
@ -11,17 +11,18 @@ class PrimImplikantCollection{
|
||||||
public:
|
public:
|
||||||
void add(PrimImplikant* &PI);
|
void add(PrimImplikant* &PI);
|
||||||
void add(string input);
|
void add(string input);
|
||||||
void add(int input);
|
void add(unsigned int input);
|
||||||
|
void add(unsigned int input1, unsigned int input2);
|
||||||
|
|
||||||
bool valueAt(int position);
|
bool valueAt(unsigned int position);
|
||||||
PrimImplikantCollection primImplikantenAt(int position);
|
PrimImplikantCollection primImplikantenAt(unsigned int position);
|
||||||
|
|
||||||
unsigned int size();
|
unsigned int size();
|
||||||
PrimImplikant* back();
|
PrimImplikant* back();
|
||||||
PrimImplikant* front();
|
PrimImplikant* front();
|
||||||
PrimImplikant* at(int const &index);
|
PrimImplikant* at(unsigned int const &index);
|
||||||
PrimImplikant* operator[](int const &index);
|
PrimImplikant* operator[](unsigned int const &index);
|
||||||
const PrimImplikant* operator[](int const &index) const;
|
const PrimImplikant* operator[](unsigned int const &index) const;
|
||||||
|
|
||||||
~PrimImplikantCollection() // destructor
|
~PrimImplikantCollection() // destructor
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue