Merge pull request #1822 from GassaFM/master

fix documentation for nextPermutation and nextEvenPermutation
This commit is contained in:
monarch dodra 2013-12-29 11:30:33 -08:00
commit 97d3f75370

View file

@ -11904,10 +11904,11 @@ unittest
---- ----
// Enumerate all permutations // Enumerate all permutations
int[] a = [1,2,3,4,5]; int[] a = [1,2,3,4,5];
while (nextPermutation(a)) do
{ {
// a now contains the next permutation of the array. // use the current permutation and
} // proceed to the next permutation of the array.
} while (nextPermutation(a));
---- ----
* Returns: false if the range was lexicographically the greatest, in which * Returns: false if the range was lexicographically the greatest, in which
* case the range is reversed back to the lexicographically smallest * case the range is reversed back to the lexicographically smallest
@ -12114,10 +12115,11 @@ unittest
---- ----
// Enumerate even permutations // Enumerate even permutations
int[] a = [1,2,3,4,5]; int[] a = [1,2,3,4,5];
while (nextEvenPermutation(a)) do
{ {
// a now contains the next even permutation of the array. // use the current permutation and
} // proceed to the next even permutation of the array.
} while (nextEvenPermutation(a));
---- ----
* One can also generate the $(I odd) permutations of a range by noting that * One can also generate the $(I odd) permutations of a range by noting that
* permutations obey the rule that even + even = even, and odd + even = odd. * permutations obey the rule that even + even = even, and odd + even = odd.
@ -12132,11 +12134,12 @@ while (nextEvenPermutation(a))
// Enumerate odd permutations // Enumerate odd permutations
int[] a = [1,2,3,4,5]; int[] a = [1,2,3,4,5];
swap(a[$-2], a[$-1]); // a is now the first odd permutation of [1,2,3,4,5] swap(a[$-2], a[$-1]); // a is now the first odd permutation of [1,2,3,4,5]
while (nextEvenPermutation(a)) do
{ {
// a now contains the next odd permutation of the original array // use the current permutation and
// proceed to the next odd permutation of the original array
// (which is an even permutation of the first odd permutation). // (which is an even permutation of the first odd permutation).
} } while (nextEvenPermutation(a));
---- ----
* *
* Warning: Since even permutations are only distinct from all permutations * Warning: Since even permutations are only distinct from all permutations