MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / quick_sort1

Function quick_sort1

publication/code/chapter07/quick_sort.rs:3–13  ·  view source on GitHub ↗
(nums: &mut [i32], low: usize, high: usize)

Source from the content-addressed store, hash-verified

1// quick_sort.rs
2
3fn quick_sort1(nums: &mut [i32], low: usize, high: usize) {
4 if low < high {
5 let split = partition(nums, low, high);
6
7 // 防止越界和语法错误(split <= 1 的情形)
8 if split > 1 {
9 quick_sort1(nums, low, split - 1);
10 }
11 quick_sort1(nums, split + 1, high);
12 }
13}
14
15// 计算分割点
16fn partition(nums: &mut [i32], low: usize, high: usize) -> usize {

Callers 1

mainFunction · 0.70

Calls 1

partitionFunction · 0.70

Tested by

no test coverage detected