auto merge of #15246 : Sawyer47/rust/rand-doc-fix, r=alexcrichton

Documentation didn't match with parameter name.
Changes name of parameter in docs and function to 'amount'.
This commit is contained in:
bors 2014-06-29 17:51:39 +00:00
commit cc5663ad55

View File

@ -244,7 +244,7 @@ pub fn random<T: Rand>() -> T {
task_rng().gen() task_rng().gen()
} }
/// Randomly sample up to `n` elements from an iterator. /// Randomly sample up to `amount` elements from an iterator.
/// ///
/// # Example /// # Example
/// ///
@ -257,11 +257,11 @@ pub fn random<T: Rand>() -> T {
/// ``` /// ```
pub fn sample<T, I: Iterator<T>, R: Rng>(rng: &mut R, pub fn sample<T, I: Iterator<T>, R: Rng>(rng: &mut R,
mut iter: I, mut iter: I,
amt: uint) -> Vec<T> { amount: uint) -> Vec<T> {
let mut reservoir: Vec<T> = iter.by_ref().take(amt).collect(); let mut reservoir: Vec<T> = iter.by_ref().take(amount).collect();
for (i, elem) in iter.enumerate() { for (i, elem) in iter.enumerate() {
let k = rng.gen_range(0, i + 1 + amt); let k = rng.gen_range(0, i + 1 + amount);
if k < amt { if k < amount {
*reservoir.get_mut(k) = elem; *reservoir.get_mut(k) = elem;
} }
} }