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

Function heapify

tests/test_common_heap.rs:4–17  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3#[test]
4fn heapify() {
5 //verify empty ok
6 let mut t: Vec<i32> = vec![];
7 let expect: Vec<i32> = vec![];
8 max_heap::heapify(&mut t, 1);
9 assert_eq!(t, expect, "t = {:?}, expect = {:?}", t, expect);
10
11 //normal
12 let t = vec![16, 4, 10, 14, 7, 9, 3, 2, 8, 1];
13 let expect = vec![16, 14, 10, 8, 7, 9, 3, 2, 4, 1];
14 let mut tt = t.clone();
15 max_heap::heapify(&mut tt, 1);
16 assert_eq!(tt, expect, "t = {:?}, expect = {:?}", t, expect);
17}
18
19#[test]
20fn build_heap() {

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected