コード例 #1
0
 public static ConditionResultArray combine(ArrayList<ArrayList<ConditionResult>> arrs) {
   ConditionResultArray arr = new ConditionResultArray();
   for (int i = 0; i < arrs.size(); i++) {
     ConditionResult r = new ConditionResult();
     for (int j = 0; j < arrs.get(i).size(); j++) {
       r.join(arrs.get(i).get(j));
     }
     arr.add(r);
   }
   return arr;
 }
コード例 #2
0
  public ConditionResultArray generateAllPath() {
    ConditionResultArray paths = new ConditionResultArray();
    // 将条件信息初始化
    ArrayList<Integer> condition = new ArrayList<Integer>();
    for (int i = 0; i < this.size(); i++) {
      int count = this.get(i).getCount();
      for (int j = 0; j < count; j++) {
        condition.add(0);
      }
    }
    // 0,1的全排列
    int count = (int) (Math.pow(2, condition.size())) - 1;

    int length = condition.size();
    for (int i = 0; i <= count; i++) {
      System.out.println("-------------------------");
      ConditionResult path = new ConditionResult();
      String strPath = Integer.toString(i, 2);
      int strPathlen = strPath.length();
      if (strPathlen < length) {
        StringBuffer s = new StringBuffer();
        for (int temp = strPathlen; temp < length; temp++) {
          s.append("0");
        }
        strPath = s + strPath;
      }
      //			System.out.println("strPath:"+strPath);
      // int zero = condition.size() - strPath.length();
      for (int j = 0; j < length; j++) {
        if (j < strPath.length()) {
          path.add(strPath.charAt(j) - 48);
        } else {
          path.add(0);
        }
        //				System.out.println("path (i="+i+"j="+j+"):"+path);
      }
      paths.add(path);
      //			System.out.println("path (i="+i+"):"+path);
      // System.out.println(Integer.toString(i, 2));
    }
    System.out.println(paths);
    return paths;
  }
コード例 #3
0
  public ConditionResultArray generateCCPath() {

    ArrayList<ArrayList<ConditionResult>> arrs = new ArrayList<ArrayList<ConditionResult>>();
    for (int i = 0; i < this.size(); i++) {
      ArrayList<ConditionResult> arr = new ArrayList<ConditionResult>();

      ConditionResult pt = new ConditionResult();
      ConditionResult pf = new ConditionResult();

      int count = this.get(i).getCount();
      for (int j = 0; j < count; j++) {
        pt.add(1);
        pf.add(0);
      }

      System.out.println("0000 pt : " + pt.toString());
      System.out.println("0000 pf : " + pf.toString());

      arr.add(pt);
      arr.add(pf);
      arrs.add(arr);
    }
    System.out.println("1111 arrs : " + arrs);
    arrs = ConditionTree.sort(arrs);
    System.out.println("2222 arrs : " + arrs);
    // Debug.println(arrs);
    ConditionResultArray pathlist = ConditionTree.combine(arrs);
    System.out.println("3333 arrs : " + arrs);
    // Debug.println(pathlist);
    return pathlist;
  }