| ... | @@ -343,7 +343,7 @@ pub const Random = struct { | ... | @@ -343,7 +343,7 @@ pub const Random = struct { |
| 343 | /// | 343 | /// |
| 344 | /// This is useful for selecting an item from a slice where weights are not equal. | 344 | /// This is useful for selecting an item from a slice where weights are not equal. |
| 345 | /// `T` must be a numeric type capable of holding the sum of `proportions`. | 345 | /// `T` must be a numeric type capable of holding the sum of `proportions`. |
| 346 | pub fn weightedIndex(r: std.rand.Random, comptime T: type, proportions: []T) usize { | 346 | pub fn weightedIndex(r: std.rand.Random, comptime T: type, proportions: []const T) usize { |
| 347 | // This implementation works by summing the proportions and picking a random | 347 | // This implementation works by summing the proportions and picking a random |
| 348 | // point in [0, sum). We then loop over the proportions, accumulating | 348 | // point in [0, sum). We then loop over the proportions, accumulating |
| 349 | // until our accumulator is greater than the random point. | 349 | // until our accumulator is greater than the random point. |