diff --git a/.gitignore b/.gitignore index bcb41c7d..524baeab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/book_out +/book /dataset /target /Cargo.lock diff --git a/book.toml b/book.toml index cb5159dc..9604de87 100644 --- a/book.toml +++ b/book.toml @@ -3,14 +3,14 @@ title = "数据结构与算法 Rust 语言实现" description = "" authors = ["Shaohua "] -src = "book" +src = "src" language = "zh-CN" [rust] edition = "2021" [build] -build-dir = "book_out" +build-dir = "book" create-missing = false [output.html] diff --git a/sorts/src/selection_sort.rs b/sorts/src/selection_sort.rs index 4fc16fdb..a445e2fb 100644 --- a/sorts/src/selection_sort.rs +++ b/sorts/src/selection_sort.rs @@ -29,7 +29,7 @@ pub fn selection_sort(list: &mut [T]) where T: PartialOrd, { - if list.is_empty() { + if list.len() < 2 { return; } let len = list.len(); diff --git a/book/SUMMARY.md b/src/SUMMARY.md similarity index 100% rename from book/SUMMARY.md rename to src/SUMMARY.md diff --git a/book/backtrace/index.md b/src/backtrace/index.md similarity index 100% rename from book/backtrace/index.md rename to src/backtrace/index.md diff --git a/book/deque/index.md b/src/deque/index.md similarity index 100% rename from book/deque/index.md rename to src/deque/index.md diff --git a/book/divide-and-conquer/index.md b/src/divide-and-conquer/index.md similarity index 100% rename from book/divide-and-conquer/index.md rename to src/divide-and-conquer/index.md diff --git a/book/dynamic-programming/index.md b/src/dynamic-programming/index.md similarity index 100% rename from book/dynamic-programming/index.md rename to src/dynamic-programming/index.md diff --git a/book/geeksforgeeks/SUMMARY.md b/src/geeksforgeeks/SUMMARY.md similarity index 100% rename from book/geeksforgeeks/SUMMARY.md rename to src/geeksforgeeks/SUMMARY.md diff --git a/book/geeksforgeeks/dsa-self-paced.md b/src/geeksforgeeks/dsa-self-paced.md similarity index 100% rename from book/geeksforgeeks/dsa-self-paced.md rename to src/geeksforgeeks/dsa-self-paced.md diff --git a/book/geeksforgeeks/most-import-type-of-algorithms.md b/src/geeksforgeeks/most-import-type-of-algorithms.md similarity index 100% rename from book/geeksforgeeks/most-import-type-of-algorithms.md rename to src/geeksforgeeks/most-import-type-of-algorithms.md diff --git a/book/geeksforgeeks/role-of-algs.md b/src/geeksforgeeks/role-of-algs.md similarity index 100% rename from book/geeksforgeeks/role-of-algs.md rename to src/geeksforgeeks/role-of-algs.md diff --git a/book/graph/breadth-first-search.md b/src/graph/breadth-first-search.md similarity index 100% rename from book/graph/breadth-first-search.md rename to src/graph/breadth-first-search.md diff --git a/book/graph/depth-first-search.md b/src/graph/depth-first-search.md similarity index 100% rename from book/graph/depth-first-search.md rename to src/graph/depth-first-search.md diff --git a/book/graph/index.md b/src/graph/index.md similarity index 100% rename from book/graph/index.md rename to src/graph/index.md diff --git a/book/graph/minimum-spanning-tree.md b/src/graph/minimum-spanning-tree.md similarity index 100% rename from book/graph/minimum-spanning-tree.md rename to src/graph/minimum-spanning-tree.md diff --git a/book/graph/shortest-path.md b/src/graph/shortest-path.md similarity index 100% rename from book/graph/shortest-path.md rename to src/graph/shortest-path.md diff --git a/book/hash-table/concurrent-hash-map.md b/src/hash-table/concurrent-hash-map.md similarity index 100% rename from book/hash-table/concurrent-hash-map.md rename to src/hash-table/concurrent-hash-map.md diff --git a/book/hash-table/hash-set.md b/src/hash-table/hash-set.md similarity index 100% rename from book/hash-table/hash-set.md rename to src/hash-table/hash-set.md diff --git a/book/hash-table/index.md b/src/hash-table/index.md similarity index 100% rename from book/hash-table/index.md rename to src/hash-table/index.md diff --git a/book/hash-table/linked-hash-map.md b/src/hash-table/linked-hash-map.md similarity index 100% rename from book/hash-table/linked-hash-map.md rename to src/hash-table/linked-hash-map.md diff --git a/book/introduction/index.md b/src/introduction/index.md similarity index 100% rename from book/introduction/index.md rename to src/introduction/index.md diff --git a/book/linked-list/double.md b/src/linked-list/double.md similarity index 100% rename from book/linked-list/double.md rename to src/linked-list/double.md diff --git a/book/linked-list/index.md b/src/linked-list/index.md similarity index 100% rename from book/linked-list/index.md rename to src/linked-list/index.md diff --git a/book/linked-list/single.md b/src/linked-list/single.md similarity index 100% rename from book/linked-list/single.md rename to src/linked-list/single.md diff --git a/book/methodology/index.md b/src/methodology/index.md similarity index 100% rename from book/methodology/index.md rename to src/methodology/index.md diff --git a/book/others/arbitrary-precision-arithmetic.md b/src/others/arbitrary-precision-arithmetic.md similarity index 100% rename from book/others/arbitrary-precision-arithmetic.md rename to src/others/arbitrary-precision-arithmetic.md diff --git a/book/others/index.md b/src/others/index.md similarity index 100% rename from book/others/index.md rename to src/others/index.md diff --git a/book/others/memory/index.md b/src/others/memory/index.md similarity index 100% rename from book/others/memory/index.md rename to src/others/memory/index.md diff --git a/book/others/permutations/index.md b/src/others/permutations/index.md similarity index 100% rename from book/others/permutations/index.md rename to src/others/permutations/index.md diff --git a/book/others/primes/index.md b/src/others/primes/index.md similarity index 100% rename from book/others/primes/index.md rename to src/others/primes/index.md diff --git a/book/others/sodoku/index.md b/src/others/sodoku/index.md similarity index 100% rename from book/others/sodoku/index.md rename to src/others/sodoku/index.md diff --git a/book/priority-queue/dual-priority-queue.md b/src/priority-queue/dual-priority-queue.md similarity index 100% rename from book/priority-queue/dual-priority-queue.md rename to src/priority-queue/dual-priority-queue.md diff --git a/book/priority-queue/index.md b/src/priority-queue/index.md similarity index 100% rename from book/priority-queue/index.md rename to src/priority-queue/index.md diff --git a/book/queue/index.md b/src/queue/index.md similarity index 100% rename from book/queue/index.md rename to src/queue/index.md diff --git a/book/refs.md b/src/refs.md similarity index 100% rename from book/refs.md rename to src/refs.md diff --git a/book/search/index.md b/src/search/index.md similarity index 100% rename from book/search/index.md rename to src/search/index.md diff --git a/book/skiplist/index.md b/src/skiplist/index.md similarity index 100% rename from book/skiplist/index.md rename to src/skiplist/index.md diff --git a/book/sorts/index.md b/src/sorts/index.md similarity index 100% rename from book/sorts/index.md rename to src/sorts/index.md diff --git a/book/stack/index.md b/src/stack/index.md similarity index 100% rename from book/stack/index.md rename to src/stack/index.md diff --git a/book/strings/index.md b/src/strings/index.md similarity index 100% rename from book/strings/index.md rename to src/strings/index.md diff --git a/book/tree/avl-tree/index.md b/src/tree/avl-tree/index.md similarity index 100% rename from book/tree/avl-tree/index.md rename to src/tree/avl-tree/index.md diff --git a/book/tree/binary-search-tree/index.md b/src/tree/binary-search-tree/index.md similarity index 100% rename from book/tree/binary-search-tree/index.md rename to src/tree/binary-search-tree/index.md diff --git a/book/tree/btree/b+-tree.md b/src/tree/btree/b+-tree.md similarity index 100% rename from book/tree/btree/b+-tree.md rename to src/tree/btree/b+-tree.md diff --git a/book/tree/btree/index.md b/src/tree/btree/index.md similarity index 100% rename from book/tree/btree/index.md rename to src/tree/btree/index.md diff --git a/book/tree/btree/map.md b/src/tree/btree/map.md similarity index 100% rename from book/tree/btree/map.md rename to src/tree/btree/map.md diff --git a/book/tree/btree/set.md b/src/tree/btree/set.md similarity index 100% rename from book/tree/btree/set.md rename to src/tree/btree/set.md diff --git a/book/tree/index.md b/src/tree/index.md similarity index 100% rename from book/tree/index.md rename to src/tree/index.md diff --git a/book/tree/red-black-tree/index.md b/src/tree/red-black-tree/index.md similarity index 100% rename from book/tree/red-black-tree/index.md rename to src/tree/red-black-tree/index.md diff --git a/book/vector/index.md b/src/vector/index.md similarity index 100% rename from book/vector/index.md rename to src/vector/index.md