If iterating over all permutations is enough for you, see this answer: Stepping through all permutations one swap at a timeStepping through all permutations one swap at a time . For a given n the iterator produces all permutations of numbers 0 to (n-1). You can simply wrap it into another iterator that converts the permutation of numbers into a permutation of your array elements. (Note that you cannot just replace int[] within the iterator with an arbitrary array/list. The algorithm needs to work with numbers.)
If iterating over all permutations is enough for you, see this answer: Stepping through all permutations one swap at a time . For a given n the iterator produces all permutations of numbers 0 to (n-1). You can simply wrap it into another iterator that converts the permutation of numbers into a permutation of your array elements. (Note that you cannot just replace int[] within the iterator with an arbitrary array/list. The algorithm needs to work with numbers.)
If iterating over all permutations is enough for you, see this answer: Stepping through all permutations one swap at a time . For a given n the iterator produces all permutations of numbers 0 to (n-1). You can simply wrap it into another iterator that converts the permutation of numbers into a permutation of your array elements. (Note that you cannot just replace int[] within the iterator with an arbitrary array/list. The algorithm needs to work with numbers.)
If iterating over all permutations is enough for you, see this answer: Stepping through all permutations one swap at a time . For a given n the iterator produces all permutations of numbers 0 to (n-1). You can simply wrap it into another iterator that converts the permutation of numbers into a permutation of your array elements. (Note that you cannot just replace int[] within the iterator with an arbitrary array/list. The algorithm needs to work with numbers.)