Skip to content

Commit 80d507c

Browse files
authored
Add Clone trait to the trees (#21)
1 parent 56d4487 commit 80d507c

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/kdtree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ where
9090
}
9191

9292
/// Internal structure used to store items in the k‑nearest neighbor heap.
93-
#[derive(Debug)]
93+
#[derive(Debug, Clone)]
9494
struct HeapItem<P> {
9595
dist: OrderedFloat<f64>,
9696
point: P,
@@ -117,7 +117,7 @@ impl<P> Ord for HeapItem<P> {
117117
}
118118

119119
/// A node in the Kd‑tree containing a point and references to its children.
120-
#[derive(Debug)]
120+
#[derive(Debug, Clone)]
121121
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
122122
struct KdNode<P: KdPoint> {
123123
point: P,
@@ -140,7 +140,7 @@ impl<P: KdPoint> KdNode<P> {
140140
///
141141
/// The tree stores points in k‑dimensional space (where `k` is provided during creation)
142142
/// and supports insertion, k‑nearest neighbor search, range search, and deletion.
143-
#[derive(Debug)]
143+
#[derive(Debug, Clone)]
144144
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
145145
pub struct KdTree<P: KdPoint> {
146146
root: Option<Box<KdNode<P>>>,

src/octree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use tracing::info;
4343
/// # Panics
4444
///
4545
/// Panics with `SpartError::InvalidCapacity` if `capacity` is zero.
46-
#[derive(Debug)]
46+
#[derive(Debug, Clone)]
4747
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4848
pub struct Octree<T: Clone + PartialEq> {
4949
boundary: Cube,

src/quadtree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use tracing::{debug, info};
4444
/// # Panics
4545
///
4646
/// Panics with `SpartError::InvalidCapacity` if `capacity` is zero.
47-
#[derive(Debug)]
47+
#[derive(Debug, Clone)]
4848
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4949
pub struct Quadtree<T: Clone + PartialEq> {
5050
boundary: Rectangle,

src/rstar_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub struct RStarTreeNode<T: RStarTreeObject> {
108108
///
109109
/// The tree is initialized with a maximum number of entries per node. If a node exceeds this
110110
/// number, it will split. The tree supports insertion, deletion, and range searches.
111-
#[derive(Debug)]
111+
#[derive(Debug, Clone)]
112112
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
113113
pub struct RStarTree<T: RStarTreeObject> {
114114
root: RStarTreeNode<T>,

src/rtree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub struct RTreeNode<T: RTreeObject> {
102102
///
103103
/// The tree is initialized with a maximum number of entries per node. If a node exceeds this
104104
/// number, it will split. The tree supports insertion, deletion, and range searches.
105-
#[derive(Debug)]
105+
#[derive(Debug, Clone)]
106106
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
107107
pub struct RTree<T: RTreeObject> {
108108
root: RTreeNode<T>,

0 commit comments

Comments
 (0)