1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
16 pub fn insert_rand_n<M, I, R>(n: uint,
21 I: FnMut(&mut M, uint),
22 R: FnMut(&mut M, uint),
25 let mut rng = rand::weak_rng();
27 for _ in range(0, n) {
28 insert(map, rng.gen::<uint>() % n);
33 let k = rng.gen::<uint>() % n;
39 pub fn insert_seq_n<M, I, R>(n: uint,
44 I: FnMut(&mut M, uint),
45 R: FnMut(&mut M, uint),
48 for i in range(0u, n) {
61 pub fn find_rand_n<M, T, I, F>(n: uint,
66 I: FnMut(&mut M, uint),
67 F: FnMut(&M, uint) -> T,
70 let mut rng = rand::weak_rng();
71 let mut keys = range(0, n).map(|_| rng.gen::<uint>() % n)
74 for k in keys.iter() {
78 rng.shuffle(keys.as_mut_slice());
83 let t = find(map, keys[i]);
89 pub fn find_seq_n<M, T, I, F>(n: uint,
94 I: FnMut(&mut M, uint),
95 F: FnMut(&M, uint) -> T,
98 for i in range(0u, n) {
105 let x = find(map, i);