Skip to content

Instantly share code, notes, and snippets.

@schmee
Created June 10, 2014 17:26
Show Gist options
  • Save schmee/f1efc71300e522420b28 to your computer and use it in GitHub Desktop.
Save schmee/f1efc71300e522420b28 to your computer and use it in GitHub Desktop.
// Version 1:
let mut n_most_common = Vec::with_capacity(n);
for _ in range(0u, n) {
let Counted { k, v } = pq.pop().unwrap();
n_most_common.push((k, v));
}
n_most_common
// ---------
// Version 2:
range(0u, n).map(|_| {
let Counted{ k, v } = pq.pop().unwrap();
(k,v)
})
.collect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment