/* * remove any identical nodes in the list by one node. */ private TList smoosh(TList min) { TList fin; Node temp, ntemp; fin = new TList(); temp = min.Head; bool check = true; while (temp != null) { ntemp = temp.Next; while (ntemp != null) { if (temp == ntemp) check = false; ntemp = ntemp.Next; } if (check) fin.addNode(temp.Value, temp.Sub, temp.Mark); check = true; temp = temp.Next; } return fin; }
public TruthTableSolver() { table = new TList(); }
/************************************************************ * Quine–McCluskey algorithm * Minimize is the function that minimize the truth table. ************************************************************* */ private TList minimize(TList mtable) { Node temp = new Node(); Node ntemp = new Node(); TList res = new TList(); bool check_end = true; int subt = 0; temp = mtable.Head; while (temp != null) { ntemp = temp.Next; while (ntemp != null) { subt = ntemp.Value - temp.Value; if (checkVaryByOneDigit(temp, ntemp)) { if ((res.Head == null) || (res.Tail.Value != temp.Value) || (res.Tail.Sub != temp.Sub + subt)) res.addNode(temp.Value, temp.Sub + subt, false); check_end = false; temp.Mark = true; ntemp.Mark = true; } ntemp = ntemp.Next; } if (!temp.Mark) res.addNode(temp.Value, temp.Sub, false); temp = temp.Next; } if (check_end) return res; return minimize(res); }