Created
June 10, 2014 17:26
-
-
Save schmee/f1efc71300e522420b28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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