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 right = vec.len() - 2;
|
||||
let mut last_succesful_swap = vec.len() -1;
|
||||
let mut last_succesful_swap = vec.len() - 1;
|
||||
|
||||
//variant of Lomuto algo.
|
||||
loop {
|
||||
@ -104,18 +104,16 @@ fn partition_kdtree<T: KdtreePointTrait>(vec: &mut Vec<T>, index_of_splitting_po
|
||||
|
||||
left += 1;
|
||||
right -= 1;
|
||||
|
||||
|
||||
} else {
|
||||
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);
|
||||
last_succesful_swap = right;
|
||||
} 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;
|
||||
} else {
|
||||
vec.swap(last_succesful_swap, vec_len - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user