Finetune Rust code.

This commit is contained in:
krahets 2023-07-26 10:01:49 +08:00
parent 06006c58a2
commit 60162f6fa8
18 changed files with 29 additions and 25 deletions

View File

@ -7,6 +7,7 @@
include!("../include/include.rs");
#[allow(dead_code)]
/* 列表类简易实现 */
struct MyList {
nums: Vec<i32>, // 数组(存储列表元素)
capacity: usize, // 列表容量

View File

@ -47,4 +47,3 @@ fn dfs(preorder: &[i32], inorder: &[i32], hmap: &HashMap<i32, i32>, i: i32, l: i
println!("构建的二叉树为:");
print_util::print_tree(root.as_ref().unwrap());
}

View File

@ -12,7 +12,9 @@ pub struct Pair {
}
/* 基于数组简易实现的哈希表 */
pub struct ArrayHashMap { buckets: Vec<Option<Pair>> }
pub struct ArrayHashMap {
buckets: Vec<Option<Pair>>
}
impl ArrayHashMap {
pub fn new() -> ArrayHashMap {

View File

@ -116,6 +116,7 @@ impl ArrayDeque {
}
}
/* Driver Code */
fn main() {
/* 初始化双向队列 */
let mut deque = ArrayDeque::new(10);

View File

@ -82,6 +82,7 @@ impl ArrayQueue {
}
}
/* Driver Code */
fn main() {
/* 初始化队列 */
let capacity = 10;