mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-30 05:43:10 +08:00
Polish rust (#1777)
* Polish rust * Update array queue and linkedlist queue * Update linkedlist deque * make array deque generic
This commit is contained in:
@ -13,22 +13,12 @@ fn test_push_max(heap: &mut BinaryHeap<i32>, val: i32) {
|
||||
println!("\n元素 {} 入堆后", val);
|
||||
print_util::print_heap(heap.iter().map(|&val| val).collect());
|
||||
}
|
||||
fn test_push_min(heap: &mut BinaryHeap<Reverse<i32>>, val: i32) {
|
||||
heap.push(Reverse(val)); // 元素入堆
|
||||
println!("\n元素 {} 入堆后", val);
|
||||
print_util::print_heap(heap.iter().map(|&val| val.0).collect());
|
||||
}
|
||||
|
||||
fn test_pop_max(heap: &mut BinaryHeap<i32>) {
|
||||
let val = heap.pop().unwrap();
|
||||
println!("\n堆顶元素 {} 出堆后", val);
|
||||
print_util::print_heap(heap.iter().map(|&val| val).collect());
|
||||
}
|
||||
fn test_pop_min(heap: &mut BinaryHeap<Reverse<i32>>) {
|
||||
let val = heap.pop().unwrap().0;
|
||||
println!("\n堆顶元素 {} 出堆后", val);
|
||||
print_util::print_heap(heap.iter().map(|&val| val.0).collect());
|
||||
}
|
||||
|
||||
/* Driver Code */
|
||||
fn main() {
|
||||
|
Reference in New Issue
Block a user