• Josh Bleecher Snyder's avatar
    math/rand: add Shuffle · a2dfe5d2
    Josh Bleecher Snyder authored
    Shuffle uses the Fisher-Yates algorithm.
    
    Since this is new API, it affords us the opportunity
    to use a much faster Int31n implementation that mostly avoids division.
    As a result, BenchmarkPerm30ViaShuffle is
    about 30% faster than BenchmarkPerm30,
    despite requiring a separate initialization loop
    and using function calls to swap elements.
    
    Fixes #20480
    Updates #16213
    Updates #21211
    
    Change-Id: Ib8956c4bebed9d84f193eb98282ec16ee7c2b2d5
    Reviewed-on: https://go-review.googlesource.com/51891
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    a2dfe5d2
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...