Skip to content

Commit

Permalink
Re-export nearest neighbor iterators so they are nameable in downstre…
Browse files Browse the repository at this point in the history
…am crates.
  • Loading branch information
adamreichold committed Nov 8, 2024
1 parent 512cda8 commit 37ad917
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions rstar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

## Added
- Added missing re-exports of nearest neighbor iterators so they can be named in downstream crates. ([PR](https://github.com/georust/rstar/pull/186))

# 0.12.2

## Changed
Expand Down
1 change: 1 addition & 0 deletions rstar/src/algorithm/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::RTree;
use smallvec::SmallVec;

pub use super::intersection_iterator::IntersectionIterator;
pub use super::nearest_neighbor::{NearestNeighborDistance2Iterator, NearestNeighborIterator};
pub use super::removal::{DrainIterator, IntoIter};

/// Iterator returned by [`RTree::locate_all_at_point`].
Expand Down
15 changes: 13 additions & 2 deletions rstar/src/algorithm/nearest_neighbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ use crate::node::{ParentNode, RTreeNode};
use crate::point::{min_inline, Point};
use crate::{Envelope, PointDistance, RTreeObject};

#[cfg(doc)]
use crate::RTree;

use alloc::collections::BinaryHeap;
#[cfg(not(test))]
use alloc::{vec, vec::Vec};
Expand Down Expand Up @@ -51,7 +54,10 @@ impl<'a, T> NearestNeighborDistance2Iterator<'a, T>
where
T: PointDistance,
{
pub fn new(root: &'a ParentNode<T>, query_point: <T::Envelope as Envelope>::Point) -> Self {
pub(crate) fn new(
root: &'a ParentNode<T>,
query_point: <T::Envelope as Envelope>::Point,
) -> Self {
let mut result = NearestNeighborDistance2Iterator {
nodes: SmallHeap::new(),
query_point,
Expand Down Expand Up @@ -106,6 +112,7 @@ where
}
}

/// Iterator returned by [`RTree::nearest_neighbor_iter_with_distance_2`].
pub struct NearestNeighborDistance2Iterator<'a, T>
where
T: PointDistance + 'a,
Expand All @@ -118,7 +125,10 @@ impl<'a, T> NearestNeighborIterator<'a, T>
where
T: PointDistance,
{
pub fn new(root: &'a ParentNode<T>, query_point: <T::Envelope as Envelope>::Point) -> Self {
pub(crate) fn new(
root: &'a ParentNode<T>,
query_point: <T::Envelope as Envelope>::Point,
) -> Self {
NearestNeighborIterator {
iter: NearestNeighborDistance2Iterator::new(root, query_point),
}
Expand All @@ -136,6 +146,7 @@ where
}
}

/// Iterator returned by [`RTree::nearest_neighbor_iter`].
pub struct NearestNeighborIterator<'a, T>
where
T: PointDistance + 'a,
Expand Down

0 comments on commit 37ad917

Please sign in to comment.