From 2d62e47f7ec3ff915d3d61fefce2a1919fea331e Mon Sep 17 00:00:00 2001 From: Jonny007-MKD <1-23-4-5@web.de> Date: Mon, 6 Jan 2014 14:57:19 +0100 Subject: [PATCH] Fixed bugs --- Hazard/Hazard/PrimImplikant.h | 44 ++++--- Hazard/Hazard/PrimImplikantCollection.cpp | 133 +--------------------- Hazard/Hazard/PrimImplikantCollection.h | 15 +-- Hazard/Hazard/Wertetabelle.h | 2 + 4 files changed, 29 insertions(+), 165 deletions(-) diff --git a/Hazard/Hazard/PrimImplikant.h b/Hazard/Hazard/PrimImplikant.h index 69d4b40..9f86294 100644 --- a/Hazard/Hazard/PrimImplikant.h +++ b/Hazard/Hazard/PrimImplikant.h @@ -2,17 +2,17 @@ #include #include -#include "Implikant_localisation.h" +#include "KV_PiEleLoc.h" using namespace std; class PrimImplikant { private: - bool compareGray(uint &a, uint &b); + static bool compareGray(uint a, uint b); void makeLocations(); - vector* locations = NULL; + vector* _locations; public: string name; @@ -21,31 +21,31 @@ public: PrimImplikant(string input) { - name = input; - parser(input); + this->name = input; + this->parser(input); + this->_locations = NULL; } PrimImplikant(uint input) { char nameC[sizeof(uint)*8+1]; _itoa_s(input, nameC, sizeof(uint)*8+1, 10); - name = nameC; + this->name = nameC; - implikanten.push_back(input); - I_Vector.push_back(new Implikant_localisation(input)); + this->elements.push_back(input); + this->_locations = NULL; } PrimImplikant(uint input1, uint input2) { char nameC[sizeof(uint)*8+1]; _itoa_s(input1, nameC, sizeof(uint)*8+1, 10); - name = nameC; + this->name = nameC; _itoa_s(input2, nameC, sizeof(uint)*8+1, 10); - name.append("|"); - name.append(nameC); + this->name.append("|"); + this->name.append(nameC); - implikanten.push_back(input1); - I_Vector.push_back(new Implikant_localisation(input1)); - implikanten.push_back(input2); - I_Vector.push_back(new Implikant_localisation(input2)); + this->elements.push_back(input1); + this->elements.push_back(input2); + this->_locations = NULL; } bool valueAt(uint position); @@ -55,15 +55,13 @@ public: ~PrimImplikant() { - if (this->locations) + if (this->_locations) { - for (uint i = 0; i < this->locations.size(); i++) - { - delete this->locations[i]; - this->locations[i] = NULL; - } - delete this->locations; - this->locations = NULL; + for (uint i = 0; i < this->_locations->size(); i++) + delete this->_locations->at(i); + + delete this->_locations; + this->_locations = NULL; } } }; \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index c24974a..7ef4595 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -1,4 +1,3 @@ -//#include #include "stdafx.h" #include #include @@ -6,6 +5,8 @@ using namespace std; +uint PrimImplikantCollection::globalCount = 0; + void PrimImplikantCollection::add(PrimImplikant* &PI) { PIVector.push_back(PI); @@ -15,21 +16,18 @@ void PrimImplikantCollection::add(string input) PrimImplikant* PI = new PrimImplikant(input); PI->id = PrimImplikantCollection::globalCount++; - this->setgroupCollection1(PI); this->add(PI); } void PrimImplikantCollection::add(uint input) { PrimImplikant* PI = new PrimImplikant(input); PI->id = PrimImplikantCollection::globalCount++; - this->setgroupCollection1(PI); this->add(PI); } void PrimImplikantCollection::add(uint input1, uint input2) { PrimImplikant* PI = new PrimImplikant(input1, input2); PI->id = PrimImplikantCollection::globalCount++; - this->setgroupCollection1(PI); this->add(PI); } @@ -58,133 +56,6 @@ bool PrimImplikantCollection::contains(PrimImplikant* foreign) return false; } - - -void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) -{ - - vector groupA; // Jede I_vector wird in einem oder in Zwei vectoren - vector groupB; // zuerst gespaltet. - - static int Linie_mitte; - uint numVarY = (uint)ceil(dimension / 2.0f); - - //PrimImplikant* currentPI = currentPI; // Zuweisung diese Adresse an einem ZeigerObjekt denselben Namen. - - - - for (vector::iterator it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) - { - if ((((*it1)->h) == (numVarY / 2) - 1) || (((*it1)->h) == (numVarY / 2))) - { - Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist. - // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind - //schalter = 1; - } - continue; - } - - if (Linie_mitte) // Wenn wahr ist. ES geht um Linie_mitte_Y - { - /*for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) - { - groupA.push_back(*it1); - } - */ - currentPI->PI_groupCollection.push_back(&(currentPI->I_Vector)); - Linie_mitte = 0; - } - else - { - for (vector::iterator it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) - { - - if ((*it1)->h < ((numVarY / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA - { // gespeichert. - - groupA.push_back(*it1); - - - } - - else { groupB.push_back(*it1); } - - } - - if (groupA.size()) - { - setgroupCollection2(currentPI, groupA); - } - - if (groupB.size()) - { - setgroupCollection2(currentPI, groupB); - } - - } - -} - - -void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vector &group) -{ - - vector hilfVec1, hilfVec2; - uint numVarX = (uint)floor(dimension / 2.0f); - static int Linie_mitte; // Zustand 0--> wird w überprüft im Vector - // Zustand 1 oder >1 -->wird w überprüft im Vector. - - - - - for (vector::iterator it1 = group.begin(); it1 < group.end(); it1++) - { - if ((((*it1)->h) == (numVarX / 2) - 1) || (((*it1)->h) == (numVarX / 2))) - { - Linie_mitte++; // test zu wissen ob die MitteLinie w der KV diagramm erreicht ist. - // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind - - } - continue; - } - - if (Linie_mitte) // Wenn wahr ist.--> Linie_mitte_X - { - - currentPI->PI_groupCollection.push_back(&group); - Linie_mitte = 0; - } - else - { - for (vector::iterator it1 = group.begin(); it1 < group.end(); it1++) - { - - if ((*it1)->w < ((numVarX / 2) - 1)) // die Implikanten, deren w <= numVarX/2 -1 sind im groupA - { // gespeichert. wenn w größer, dann wird im hilfVec2 gespeichert - - hilfVec1.push_back(*it1); - - - } - - else { hilfVec2.push_back(*it1); } - - } - - if (hilfVec1.size()) - { - currentPI->PI_groupCollection.push_back(&hilfVec1); - } - - if (hilfVec2.size()) - { - currentPI->PI_groupCollection.push_back(&hilfVec2); - } - - } -} - - uint PrimImplikantCollection::size() { return this->PIVector.size(); diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index 60edc11..3f5ef7a 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -1,17 +1,14 @@ -//#include +#pragma once + #include #include #include "PrimImplikant.h" -#include "Implikant_localisation.h" using namespace std; extern uint dimension; extern uint numElements; extern bool KNF; -#ifndef PRIMIMPLIKANTCOLLEC -#define PRIMIMPLIKANTCOLLEC - class PrimImplikantCollection{ public: void add(PrimImplikant* &PI); @@ -22,8 +19,6 @@ public: bool valueAt(uint position); PrimImplikantCollection primImplikantenAt(uint position); bool contains(PrimImplikant* foreign); - void setgroupCollection1(PrimImplikant* ¤tPI); - void setgroupCollection2(PrimImplikant* ¤tPI,vector &group); void Dispose(); @@ -36,7 +31,5 @@ public: private: vector PIVector; - static uint globalCount = 0; -}; - -#endif \ No newline at end of file + static uint globalCount; +}; \ No newline at end of file diff --git a/Hazard/Hazard/Wertetabelle.h b/Hazard/Hazard/Wertetabelle.h index e13b54a..9170289 100644 --- a/Hazard/Hazard/Wertetabelle.h +++ b/Hazard/Hazard/Wertetabelle.h @@ -1,3 +1,5 @@ +#pragma once + #include "stdafx.h" #include #include