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

readme: hilight remove fn assumes coords not changed #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ Remove all items:
tree.clear();
```

**warning**

The remove implementation relies on the coordinates of the object to be the same as when it was inserted.
This is because the fn is optimised to only look for the object to remove in the sections of the tree it expects them to be in, based on the coordinates of the item being removed.

This will cause issues

```js

// bad
obj.minX += 5
obj.maxX -= 5
tree.remove(obj)
tree.insert(obj)

// you may end up with two copies of the object

// good
tree.remove(obj)
obj.minX += 5
obj.maxX -= 5
tree.insert(obj)
```

### Data Format

By default, RBush assumes the format of data points to be an object
Expand Down