mozilla/rust — pull request #5127 by tmmcguire (2013-02-26 21:15:23+00:00)
Title: Faster each permutation

This is a replacement each_permutation that is somewhat faster than the previous version (and 2x faster, according to my testing, than the versions on the mailing list in January). The algorithm is based on "Generation in lexicographic order" section in Wikipdedia (http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order).

I also exposed a function to reverse a portion of a vector which is used by the algorithm and seems like it might be something someone would want.

Finally, there's a each_permutation_ref that eliminates the Copy type requirement.