Created
June 1, 2014 00:03
-
-
Save schmee/c403b3ab29b178c4b4b5 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
pub fn most_common(&self, n: uint) -> Vec<(K, uint)> { | |
let data = self.data.clone(); | |
let mut counted: Vec<Counted<K>> = data.move_iter(). | |
map(|(k, v)| Counted {k: k, v: v}).collect(); | |
let mut n_most_common = vec!(); | |
let mut pq = PriorityQueue::from_vec(counted); | |
for _ in range(0u, n) { | |
let tmp = pq.pop().unwrap(); | |
// error: use of partially moved value: `tmp` | |
let pair = (tmp.k, tmp.v); | |
n_most_common.push(pair); | |
} | |
n_most_common | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment