MCPcopy Create free account
hub / github.com/douchuan/algorithm / min_pq

Function min_pq

tests/test_common.rs:51–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50#[test]
51fn min_pq() {
52 //case-1, test insert & del_min
53 let t = vec![4, 1, 3, 2, 16, 9, 10, 14, 8, 7];
54 let mut min_pq = PQ::new_min_pq(t.len());
55 for v in &t {
56 min_pq.enqueue(*v);
57 }
58 assert!(!min_pq.is_empty());
59 assert_eq!(t.len(), min_pq.len());
60 assert_eq!(Some(1), min_pq.peek().cloned());
61 for v in vec![1, 2, 3, 4, 7, 8, 9, 10, 14, 16] {
62 assert_eq!(min_pq.dequeue(), Some(v));
63 }
64 assert!(min_pq.is_empty());
65 assert_eq!(0, min_pq.len());
66 assert_eq!(None, min_pq.peek());
67 assert_eq!(min_pq.dequeue(), None);
68}
69
70#[test]
71fn max_pq() {

Callers

nothing calls this directly

Calls 2

lenMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected