Skip to content

Commit

Permalink
Remove actually unused depth parameter and make Clippy happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed Jul 29, 2023
1 parent cb6fe73 commit 8b60c5d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
10 changes: 3 additions & 7 deletions rstar/src/algorithm/bulk_load/bulk_load_sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use num_traits::Float;

use super::cluster_group_iterator::{calculate_number_of_clusters_on_axis, ClusterGroupIterator};

fn bulk_load_recursive<T, Params>(elements: Vec<T>, depth: usize) -> ParentNode<T>
fn bulk_load_recursive<T, Params>(elements: Vec<T>) -> ParentNode<T>
where
T: RTreeObject,
<T::Envelope as Envelope>::Point: Point,
Expand All @@ -28,7 +28,6 @@ where

let iterator = PartitioningTask::<_, Params> {
number_of_clusters_on_axis,
depth,
work_queue: vec![PartitioningState {
current_axis: <T::Envelope as Envelope>::Point::DIMENSIONS,
elements,
Expand All @@ -50,7 +49,6 @@ struct PartitioningState<T: RTreeObject> {
/// Successively partitions the given elements into cluster groups and finally into clusters.
struct PartitioningTask<T: RTreeObject, Params: RTreeParams> {
work_queue: Vec<PartitioningState<T>>,
depth: usize,
number_of_clusters_on_axis: usize,
_params: core::marker::PhantomData<Params>,
}
Expand All @@ -66,7 +64,7 @@ impl<T: RTreeObject, Params: RTreeParams> Iterator for PartitioningTask<T, Param
} = next;
if current_axis == 0 {
// Partitioning finished successfully on all axis. The remaining cluster forms a new node
let data = bulk_load_recursive::<_, Params>(elements, self.depth - 1);
let data = bulk_load_recursive::<_, Params>(elements);
return RTreeNode::Parent(data).into();
} else {
// The cluster group needs to be partitioned further along the next axis
Expand Down Expand Up @@ -95,9 +93,7 @@ where
<T::Envelope as Envelope>::Point: Point,
Params: RTreeParams,
{
let m = Params::MAX_SIZE;
let depth = (elements.len() as f32).log(m as f32).ceil() as usize;
bulk_load_recursive::<_, Params>(elements, depth)
bulk_load_recursive::<_, Params>(elements)
}

#[cfg(test)]
Expand Down
6 changes: 3 additions & 3 deletions rstar/src/algorithm/nearest_neighbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ where
T: PointDistance,
{
fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> {
// Inverse comparison creates a min heap
other.distance.partial_cmp(&self.distance)
Some(self.cmp(other))
}
}

Expand All @@ -40,7 +39,8 @@ where
T: PointDistance,
{
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
self.partial_cmp(other).unwrap()
// Inverse comparison creates a min heap
other.distance.partial_cmp(&self.distance).unwrap()
}
}

Expand Down
2 changes: 1 addition & 1 deletion rstar/src/algorithm/rstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ where
}
}

fn choose_subtree<T>(node: &mut ParentNode<T>, to_insert: &RTreeNode<T>) -> usize
fn choose_subtree<T>(node: &ParentNode<T>, to_insert: &RTreeNode<T>) -> usize
where
T: RTreeObject,
{
Expand Down

0 comments on commit 8b60c5d

Please sign in to comment.