|
Get the next permutation in lexicographic order. Starting with the identity permutation and repeatedly applying this function will iterate through all possible permutations. If no further permutation is available the current permutation will not change.
If we start with (1,2,3,4) successively applying Next will generate the following sequence (1,2,4,3), (1,3,2,4), (1,3,4,2), (1,4,2,3), (1,4,3,2), etc.
© djmw, May 21, 2010