mirror of
https://github.com/andreytkachenko/kdtree-rust.git
synced 2024-11-22 01:16:25 +04:00
Add method
This commit is contained in:
parent
73bacad7ba
commit
99e465ba6e
@ -90,7 +90,6 @@ impl<'a, F: Float, T> Iterator for NearestNeighboursIter<'a, F, T>
|
||||
|
||||
pub struct KdTree<F: Float, KP> {
|
||||
nodes: Vec<KdTreeNode<F, KP>>,
|
||||
|
||||
node_adding_dimension: usize,
|
||||
node_depth_during_last_rebuild: usize,
|
||||
current_node_depth: usize,
|
||||
@ -299,17 +298,25 @@ impl<F: Float, KP: KdTreePoint<F>> KdTree<F, KP> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn into_iter(self) -> impl Iterator<Item = KP> {
|
||||
pub fn into_iter(self) -> impl Iterator<Item = KP> {
|
||||
self.nodes
|
||||
.into_iter()
|
||||
.map(|node|node.point)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn iter(&self) -> impl Iterator<Item = &KP> {
|
||||
self.nodes
|
||||
.iter()
|
||||
.map(|node|&node.point)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub struct KdTreeNode<F: Float, T> {
|
||||
left_node: Option<usize>,
|
||||
right_node: Option<usize>,
|
||||
|
||||
point: T,
|
||||
dimension: usize,
|
||||
split_on: F
|
||||
@ -328,6 +335,8 @@ impl<F: Float, T: KdTreePoint<F>> KdTreeNode<F, T> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::kdtree::test_common::Point2WithId;
|
||||
|
Loading…
Reference in New Issue
Block a user