コード例 #1
0
  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;
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  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;
  }