mirror of
https://github.com/andreytkachenko/kdtree-rust.git
synced 2024-11-22 09:26:25 +04:00
Formatted code slightly
This commit is contained in:
parent
ce6cd45464
commit
9d58383801
@ -86,7 +86,7 @@ fn partition_kdtree<T: KdtreePointTrait>(vec: &mut Vec<T>, index_of_splitting_po
|
|||||||
|
|
||||||
let mut left = 0usize;
|
let mut left = 0usize;
|
||||||
let mut right = vec.len() - 2;
|
let mut right = vec.len() - 2;
|
||||||
let mut last_succesful_swap = vec.len() -1;
|
let mut last_succesful_swap = vec.len() - 1;
|
||||||
|
|
||||||
//variant of Lomuto algo.
|
//variant of Lomuto algo.
|
||||||
loop {
|
loop {
|
||||||
@ -104,18 +104,16 @@ fn partition_kdtree<T: KdtreePointTrait>(vec: &mut Vec<T>, index_of_splitting_po
|
|||||||
|
|
||||||
left += 1;
|
left += 1;
|
||||||
right -= 1;
|
right -= 1;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if last_succesful_swap == vec_len -1 && vec[right].dims()[partition_on_dimension] > pivot {
|
if last_succesful_swap == vec_len - 1 && vec[right].dims()[partition_on_dimension] > pivot {
|
||||||
vec.swap(right, last_succesful_swap);
|
vec.swap(right, last_succesful_swap);
|
||||||
last_succesful_swap = right;
|
last_succesful_swap = right;
|
||||||
} else if vec[left].dims()[partition_on_dimension] > pivot {
|
} else if vec[left].dims()[partition_on_dimension] > pivot {
|
||||||
vec.swap(left, vec_len -1);
|
vec.swap(left, vec_len - 1);
|
||||||
last_succesful_swap = left;
|
last_succesful_swap = left;
|
||||||
} else {
|
} else {
|
||||||
vec.swap(last_succesful_swap, vec_len - 1);
|
vec.swap(last_succesful_swap, vec_len - 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user