Permalink
Browse files

I was using ArrayList (which is not available in Silverlight) interna…

…lly Array#sample. Update to use List<object>
  • Loading branch information...
1 parent adfd117 commit 7975d9e480a778a4c5900071fccd11f56c48a08a Orion Edwards [GGL] committed Jan 31, 2012
Showing with 8 additions and 6 deletions.
  1. +8 −6 Languages/Ruby/Libraries/Extensions/IListOps.cs
@@ -1952,12 +1952,14 @@ public static class IListOps {
var generator = allocateStorage.Context.RandomNumberGenerator;
// we can't pick the same element twice, so remove items from a copy of the list as we pick them
- var itemsRemaining = new ArrayList(self);
-
- while (itemsRemaining.Count > 0 && elementCount--> 0) {
- var idx = generator.Next(itemsRemaining.Count);
- result.Add(itemsRemaining[idx]);
- itemsRemaining.RemoveAt(idx);
+ var remaining = new List<object>(self.Count); // can't use ArrayList here as silverlight doesn't have it
+ foreach (var x in self)
+ remaining.Add(x);
+
+ while (remaining.Count > 0 && elementCount-- > 0) {
+ var idx = generator.Next(remaining.Count);
+ result.Add(remaining[idx]);
+ remaining.RemoveAt(idx);
}
return result;

0 comments on commit 7975d9e

Please sign in to comment.