Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement nearest_neighbour_mut #114

Open
joverwey opened this issue Feb 20, 2023 · 2 comments
Open

Implement nearest_neighbour_mut #114

joverwey opened this issue Feb 20, 2023 · 2 comments

Comments

@joverwey
Copy link

The nearest_neighbour() function returns an immutable reference to and existing node.
Nodes with data associated with it, like GeomWithData<[f32;3], usize>, cannot be modified inplace.
Instead one has to use pop_nearest_neighbor, change the data, and then reinsert it.

An use example case for this is an rtree that keeps visitation counts for a set of positions.

@rmanoka
Copy link
Contributor

rmanoka commented Feb 21, 2023

This is by design as we don't want the geometry to change. Try GeomWithData<G, Cell<T>> . Then you can replace the inner T as per Cell semantics (incl. replace with immutable ref. if T is copy; usize is)

@grovesNL
Copy link
Contributor

Does locate_in_envelope_intersecting_mut have the same issue? It seems like it allows us to change the geometry, but the tree wouldn't know that the envelope haw changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants