List of utility methods to do String Permutation
boolean | getNextPermutation(StringBuilder sb) get Next Permutation List<Character> list = asList(sb.toString().toCharArray()); boolean ret = getNextPermutation(list); Object[] array = list.toArray(); sb.delete(0, sb.length()); sb.append(toCharArray(array)); return ret; |
boolean | getRandomPermutation(StringBuilder sb) get Random Permutation for (int i = 0; i != sb.length(); ++i) { if (!getNextPermutation(sb)) return false; return true; |