diff --git a/src/kdtree/mod.rs b/src/kdtree/mod.rs index f456956..3d0dcb0 100644 --- a/src/kdtree/mod.rs +++ b/src/kdtree/mod.rs @@ -80,17 +80,22 @@ pub struct KdTree { } impl KdTree { + #[inline] + pub fn empty() -> Self { + KdTree { + nodes: vec![], + node_adding_dimension: 0, + node_depth_during_last_rebuild: 0, + current_node_depth: 0, + } + } + pub fn new(mut points: &mut [KP]) -> Self { if points.len() == 0 { panic!("empty vector point not allowed"); } - let mut tree = KdTree { - nodes: vec![], - node_adding_dimension: 0, - node_depth_during_last_rebuild: 0, - current_node_depth: 0, - }; + let mut tree = Self::empty(); tree.rebuild_tree(&mut points);