mourner/rbush

Questions: Performance Remove + Moving item

anonym-HPI opened this issue · 1 comments

Hi,

I am implementing rbush (and using rbush-knn also) to get items around another item.
Items have an id and position (items are represented as points, so minX=maxX and MinY=MaxY).

About performance, I have a few questions and what would probably be more efficient (fromJSON is used before, so no references):

  1. When removing an item by value, if I know the position (and therefore the BBox) and the id, what would be more efficient:
    a. Using search and then using the first item that I found and then remove the item per reference via remove or
    b. Remove the item per id (like described in the examples)
  2. When moving and item around, is it better to first insert and then remove it or the other way around?

In general I'd recommend benchmarking any approach to validate it, I can't say for sure. For 1, I would use option b because it's one step of going through the items instead of two. For 2, removing and then inserting is probably faster. For discussion on how this could be improved in the future, see #28