Polish rust (#1777)

* Polish rust

* Update array queue and linkedlist queue

* Update linkedlist deque

* make array deque generic
This commit is contained in:
rongyi
2025-07-10 06:33:22 +08:00
committed by GitHub
parent e8dc4736a2
commit b0c147b67c
8 changed files with 41 additions and 47 deletions

View File

@ -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() {