Bug fixes and improvements (#1732)

* Bug fixes

* Sync zh and zh-hant versions.

* "入列列" -> "入佇列"

* Fix hello_algo_mindmap.png
This commit is contained in:
Yudong Jin
2025-04-10 19:21:52 +08:00
committed by GitHub
parent a9d44c3a25
commit 8e38c61455
14 changed files with 48 additions and 49 deletions
@@ -19,8 +19,7 @@ struct MyList {
impl MyList {
/* 建構子 */
pub fn new(capacity: usize) -> Self {
let mut vec = Vec::new();
vec.resize(capacity, 0);
let mut vec = vec![0; capacity];
Self {
arr: vec,
capacity,
@@ -92,7 +91,7 @@ impl MyList {
};
let num = self.arr[index];
// 將將索引 index 之後的元素都向前移動一位
for j in (index..self.size - 1) {
for j in index..self.size - 1 {
self.arr[j] = self.arr[j + 1];
}
// 更新元素數量
@@ -111,7 +110,7 @@ impl MyList {
}
/* 將串列轉換為陣列 */
pub fn to_array(&mut self) -> Vec<i32> {
pub fn to_array(&self) -> Vec<i32> {
// 僅轉換有效長度範圍內的串列元素
let mut arr = Vec::new();
for i in 0..self.size {