mirror of
https://github.com/krahets/hello-algo.git
synced 2025-01-23 14:20:29 +08:00
Finetune Rust code.
This commit is contained in:
parent
06006c58a2
commit
60162f6fa8
@ -7,6 +7,7 @@
|
|||||||
include!("../include/include.rs");
|
include!("../include/include.rs");
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
/* 列表类简易实现 */
|
||||||
struct MyList {
|
struct MyList {
|
||||||
nums: Vec<i32>, // 数组(存储列表元素)
|
nums: Vec<i32>, // 数组(存储列表元素)
|
||||||
capacity: usize, // 列表容量
|
capacity: usize, // 列表容量
|
||||||
|
@ -47,4 +47,3 @@ fn dfs(preorder: &[i32], inorder: &[i32], hmap: &HashMap<i32, i32>, i: i32, l: i
|
|||||||
println!("构建的二叉树为:");
|
println!("构建的二叉树为:");
|
||||||
print_util::print_tree(root.as_ref().unwrap());
|
print_util::print_tree(root.as_ref().unwrap());
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,9 @@ pub struct Pair {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 基于数组简易实现的哈希表 */
|
/* 基于数组简易实现的哈希表 */
|
||||||
pub struct ArrayHashMap { buckets: Vec<Option<Pair>> }
|
pub struct ArrayHashMap {
|
||||||
|
buckets: Vec<Option<Pair>>
|
||||||
|
}
|
||||||
|
|
||||||
impl ArrayHashMap {
|
impl ArrayHashMap {
|
||||||
pub fn new() -> ArrayHashMap {
|
pub fn new() -> ArrayHashMap {
|
||||||
|
@ -116,6 +116,7 @@ impl ArrayDeque {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Driver Code */
|
||||||
fn main() {
|
fn main() {
|
||||||
/* 初始化双向队列 */
|
/* 初始化双向队列 */
|
||||||
let mut deque = ArrayDeque::new(10);
|
let mut deque = ArrayDeque::new(10);
|
||||||
|
@ -82,6 +82,7 @@ impl ArrayQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Driver Code */
|
||||||
fn main() {
|
fn main() {
|
||||||
/* 初始化队列 */
|
/* 初始化队列 */
|
||||||
let capacity = 10;
|
let capacity = 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user