forked from githubofhuo/KARNAUGH-MAP-MINIMIZER
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KARNAUGHMAP.H
67 lines (60 loc) · 2.77 KB
/
KARNAUGHMAP.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
* Copyright (C) 2005 by Robert Kovacevic *
* robert.kovacevic@etfos.hr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef KARNAUGH_MAP_H
#define KARNAUGH_MAP_H
#include <vector>
#include <list>
#include <map>
#include <utility>
using namespace std;
struct KarnaughNode
{
vector<unsigned short int> values;
unsigned int numberOfItems;
bool flag;
};
class KarnaughMap
{
public:
KarnaughMap(int n);
void Reset();
void Set(unsigned int x, unsigned int y, unsigned short int value);
unsigned short int Get(unsigned int x, unsigned int y);
unsigned int GetMapValue(unsigned int x, unsigned int y);
vector<unsigned short int> GetMapBoolValue(unsigned int x, unsigned int y);
bool IsAtCell(int x, int y, vector<unsigned short int> a);
unsigned int const GetWidth();
unsigned int const GetHeight();
unsigned int const GetNumberOfVars();
list <KarnaughNode> GetSolutions();
void Solve();
private:
void Solve2();
unsigned int GrayEncode(unsigned int g);
unsigned int IsJoinable(vector<unsigned short int> a, vector<unsigned short int> b);
map <pair<unsigned int, unsigned int>, unsigned short int> kmap;
map <pair<unsigned int, unsigned int>, unsigned int> kmapValues;
map <pair<unsigned int, unsigned int>, bool> kmapDCare;
list <KarnaughNode> blocks;
unsigned int numberOfDCares;
unsigned int numberOfVariables;
unsigned int width, height;
};
#endif // KARNAUGH_MAP_H