Added back(), front(), at(int) and destructor of PrimImplikantCollection

This commit is contained in:
Jonny007-MKD 2013-11-12 23:58:15 +01:00
parent c8c36676b4
commit 5608f2b400
7 changed files with 38 additions and 7 deletions

View File

@ -118,8 +118,8 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector<string>* &variables)
else if ((yylval.i == 0) ^ KNF)
{
fprintf(IP_Error, "*** FATAL ERROR *** You can only define either KNF or DNF!\n");
fprintf(IP_Error, "In line %3d: %s>%i", pic->back()->name, yylval.i);
fprintf(IP_Error, "In line %3d: Defined was: %s, but now shall be changed to %s", (int)IP_LineNumber, KNF ? "KNF" : "DNF", KNF ? "DNF" : "KNF");
fprintf(IP_Error, "In line %3d: %s>%i\n", (int)IP_LineNumber, pic->back()->name.c_str(), yylval.i);
fprintf(IP_Error, "In line %3d: Defined was: %s, but now shall be changed to %s\n\n", (int)IP_LineNumber, KNF ? "KNF" : "DNF", KNF ? "DNF" : "KNF");
printf("*** FATAL ERROR *** You can only define either KNF or DNF!\n");
return 1;
}

View File

@ -12,8 +12,8 @@
using namespace std;
unsigned int dimension = 0;
unsigned int numElements = 0;
unsigned int dimension = 0; // = variables.size()
unsigned int numElements = 0; // = 2 ^ dimension
bool KNF = false;
int _tmain(int argc, _TCHAR* argv[])
@ -28,7 +28,7 @@ int _tmain(int argc, _TCHAR* argv[])
system("pause");
return -1;
}
fopen_s(&error, "..\\res\\errorParser.txt", "w");
fopen_s(&error, "..\\res\\errorParser.txt", "a");
if (error == 0)
{
cout << "Fehler Fehlerdatei";

View File

@ -40,4 +40,19 @@ PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(int position)
unsigned int PrimImplikantCollection::size()
{
return this->PIVector.size();
}
PrimImplikant* PrimImplikantCollection::back()
{
return this->PIVector.back();
}
PrimImplikant* PrimImplikantCollection::front()
{
return this->PIVector.front();
}
PrimImplikant* PrimImplikantCollection::at(int const &index)
{
return this->PIVector.at(index);
}

View File

@ -19,11 +19,15 @@ public:
unsigned int size();
PrimImplikant* back();
PrimImplikant* front();
PrimImplikant* at();
PrimImplikant* at(int const &index);
PrimImplikant* operator[](int const &index);
const PrimImplikant* operator[](int const &index) const;
~PrimImplikantCollection(); // destructor
~PrimImplikantCollection() // destructor
{
for (unsigned int i = 0; i < this->size(); i++)
delete this->at(i);
}
private:
vector<PrimImplikant*> PIVector;
};

View File

@ -0,0 +1,12 @@
*** FATAL ERROR *** You can only define either KNF or DNF!
In line 8211212: (null)>-1105314512
In line 4: Defined was: DNF, but now shall be changed to KNF
*** FATAL ERROR *** You can only define either KNF or DNF!
In line 4: 7>0
In line 4: Defined was: DNF, but now shall be changed to KNF
*** FATAL ERROR *** You can only define either KNF or DNF!
In line 4: 7>1
In line 4: Defined was: KNF, but now shall be changed to DNF

View File