求大项集的所有子集(字符串的所有子集)
public List<String> getSubSet(String largeItemSet) { List<String> list = new ArrayList<String>(); char[] lisChar = largeItemSet.toCharArray(); for(int i = 0; i < lisChar.length; i++) { list.add(new String(lisChar[i] + "")); } for(int j = 0; j < list.size(); j++) { for(int k = 0; k < lisChar.length; k++) { if(list.get(j).indexOf(new String(lisChar[k] + "")) == -1) { String tempStr = list.get(j) + new String(lisChar[k] + ""); list.add(tempStr); } } } return list; }
String str = "abcdefgh";
init:deps-jar:Warning: _asi\Main.java modified in the future.Compiling 1 source file to E:\JavaProject\02_ASI_1\build\classescompile:run:count:1 subSet.get(i):acount:2 subSet.get(i):bcount:3 subSet.get(i):ccount:4 subSet.get(i):d...count:109590 subSet.get(i):hgfecadbcount:109591 subSet.get(i):hgfecbadcount:109592 subSet.get(i):hgfecbdacount:109593 subSet.get(i):hgfecdabcount:109594 subSet.get(i):hgfecdbacount:109595 subSet.get(i):hgfedabccount:109596 subSet.get(i):hgfedacbcount:109597 subSet.get(i):hgfedbaccount:109598 subSet.get(i):hgfedbcacount:109599 subSet.get(i):hgfedcabcount:109600 subSet.get(i):hgfedcba成功生成(总时间:22 秒)