quadtree icon indicating copy to clipboard operation
quadtree copied to clipboard

Why are you using a hashmap ?

Open LucaCoduriV opened this issue 2 years ago • 2 comments

Hello, I was looking your code to learn how a Quadtree could be implemented in rust (I never did it before in any other language too). But I was wondering why are you using a hashmap for your store ? Wouldn't it be faster with an array ? So your handle would just be a index of you array ? I mean getting a value in a hashmap is O(1) but it's still slower than getting a value in an array.

LucaCoduriV avatar Mar 01 '23 17:03 LucaCoduriV

Hi Luca, thanks for your question.

One reason that I used a hashmap for this project was that it supported the needs I knew of at the time (performant queries, insertion, deletion) without any complexity at all. I suspect that using an array would be faster and simpler in some respects, but I didn't want to think through the complexity of deletes, hanging handles, etc. It might well be the case that an array serves all of these needs just as easily.

I don't have a ton of bandwidth for this project right now but I'd be very happy to review a PR.

ambuc avatar Mar 02 '23 23:03 ambuc

Thank you for your response 😃 I'll try to make a pull request if I have time.

Thank you for your repo too, I learned a lot with it.

LucaCoduriV avatar Mar 04 '23 16:03 LucaCoduriV