sdd / kiddo

Kiddo
Apache License 2.0
85 stars 14 forks source link

Item value change #93

Open Indy2222 opened 10 months ago

Indy2222 commented 10 months ago

Add a method to exchange a value of a point.

pub fn exchange(&mut self, query: &[A; K], old_item: T, new_item: T);

Use case:

I have a KdTree with indices to Vec<Slot> because Slot is too large to be efficiently stored directly in the KdTree. When removing an entity, one can efficiently remove it from the Vec with Vec::swap_remove(index) which moves the last slot to index. This creates the need to change the stored index inside KdTree of the moved item.

sdd commented 10 months ago

Seems like a useful feature - happy to accept a PR for this. I won't have time to get around to implementing this for a while myself.