Sha256: 7a40f5477fad34caa45bb8416aa6b4387108ae7b8b2aa5f7f9c77c6927b59812
Contents?: true
Size: 581 Bytes
Versions: 2
Compression:
Stored size: 581 Bytes
Contents
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved. # License:: GNU General Public License (GPL). # Revision:: $Id: shuffle.rb 220 2005-05-09 12:28:26Z ertai $ class Array def shuffle! ( generator=nil ) n = size n.times do |i| swap!(i, n.choose(generator)) end self end def shuffle ( generator=nil ) dup.shuffle!(generator) end def swap! ( i, j ) self[i], self[j] = self[j], self[i] end def swap ( i, j ) dup.swap!(i, j) end end # class Array
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ruby_ex-0.1.1 | src/shuffle.rb |
vcs-0.2.148 | ruby_ex/shuffle.rb |