Skip to content

Commit

Permalink
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions kernel/common/array.rb
Original file line number Diff line number Diff line change
@@ -1365,28 +1365,38 @@ def sample(count=undefined, options=undefined)
else
if size / count > 3
abandon = false
spin = 0

result = Array.new count
i = 1

result[0] = rng.rand(size)
while i < count
k = rng.rand(size)
j = 0

while j < i
while k == result[j]
spin += 1
if spin > 100
spin = false
spin_count = 0

while true
j = 0
while j < i
if k == result[j]
spin = true
break
end

j += 1
end

if spin
if (spin_count += 1) > 100
abandon = true
break
end

k = rng.rand(size)
else
break
end
break if abandon

j += 1
end

break if abandon

0 comments on commit deabe67

Please sign in to comment.