private boolean listContainsEquation( ArrayList<Element> list, ArrayList<Element> equationElement) { ArrayList<Element> listClone = list.clone(); for (Element element : equationElement) { if (listClone.contains(element)) listClone.remove(element); else return false; } return true; }
public ArrayList<Element> trimElements(ArrayList<Element> list) { ArrayList<Element> listOld = list.clone(); for (ArrayList<Element> equationElement : this.equations.getKeys()) { if (!listContainsEquation(list, equationElement)) continue; list = removeEquationFromList(list, equationElement); list = addEquationToList(list, this.equations.getValue(equationElement)); list = sortList(list); printTrim(equationElement, listOld, list); list = trimElements(list); break; } return list; }
public boolean isPerfectPosition(ArrayList<Element> list) { for (ArrayList<Element> pPosition : this.perfectPositions) { if (pPosition.size() != list.size()) continue; ArrayList<Element> listTemp = list.clone(); boolean notFound = false; for (Element element : pPosition) if (listTemp.contains(element)) listTemp.remove(element); else notFound = true; if (notFound) continue; if (!listTemp.isEmpty()) continue; return true; } return false; }