Avoiding having to calculate the gcd when doing cycle decomposition -- Raymond Chen
Last time, we looked at how clang’s libcxx implementation of std::rotate uses cycle decomposition to minimize the number of swaps. Doing so requires calculating the greatest common divisor, but I noted that the OpenJDK implementation of the java standard library uses a trick to avoid doing the gcd…
Sources
- T1Avoiding having to calculate the gcd when doing cycle decomposition -- Raymond ChenLanguage blogs: Rust / Go / TypeScript / Swift / Kotlin / Java / .NET / Ruby / PHP / Elixir / ISO C++