MCPcopy Index your code
hub / github.com/douchuan/algorithm / insert

Method insert

src/common/top_m.rs:19–26  ·  view source on GitHub ↗
(&mut self, v: T)

Source from the content-addressed store, hash-verified

17 }
18
19 pub fn insert(&mut self, v: T) {
20 self.pq.enqueue(v);
21 // remove minimum if m+1 entries on the PQ
22 if self.pq.len() > self.m {
23 let _ = self.pq.dequeue();
24 }
25 // top m entries are on the PQ
26 }
27
28 pub fn into_vec(mut self) -> Vec<T> {
29 let mut vec = Vec::with_capacity(self.m);

Callers 15

newMethod · 0.45
putMethod · 0.45
top_mFunction · 0.45
rb_tree_heightFunction · 0.45
heightFunction · 0.45
insert1Function · 0.45
insert2Function · 0.45
repeat_insertFunction · 0.45
delete_minFunction · 0.45
delete_maxFunction · 0.45
deleteFunction · 0.45
min_maxFunction · 0.45

Calls 3

enqueueMethod · 0.45
lenMethod · 0.45
dequeueMethod · 0.45

Tested by 15

top_mFunction · 0.36
rb_tree_heightFunction · 0.36
heightFunction · 0.36
insert1Function · 0.36
insert2Function · 0.36
repeat_insertFunction · 0.36
delete_minFunction · 0.36
delete_maxFunction · 0.36
deleteFunction · 0.36
min_maxFunction · 0.36
keysFunction · 0.36
drop_clearFunction · 0.36