-
Notifications
You must be signed in to change notification settings - Fork 21
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
Make Quadtree's Box and Point private? #34
Comments
Agreed it would be nice to not expose At first glance, the best way I'm seeing to implement this is by adding the
The downside of this implementation is it exposes |
|
Good point, I'll give it a closer look later today. |
Here just have a look at what I came up with (actually required more refactoring of tests than actual code). |
I employed some argument shifting since I wasn't sure internally where |
Looks good. The argument shifting allows the code to be more extendable and has no functional issues, but I think it is confusing to someone not familiar with the codebase. It would be a good idea to add some comments here. I can also add the correct recursive calls, which would allow us to ditch the argument shifting. |
I'd prefer commenting over changing all the recursive calls. For one, we have to re-instantiate a // ... other code ..
nearestPoints = quadtree.retrieve(searchBox.minX, searchBox.minY, searchBox.maxX, searchBox.maxY ); |
Yeah realize the method calls get messy. Either way works, but fine with commenting. |
@davegw
I'm wondering if we can refactor
Quadtree
to avoid exposingBox
andPoint
to users. For example, maybe the Quadtree constructor would look like thisThis ensures that the
box
property of anyQuadtree
is actually aBox
instance. Further, by keepingBox
private, we don't have to worry about documenting it.for
Quadtree.prototype.insert
, something like this:Haven't had a chance to dive deep into the implementation but I'm wondering if you think this would be 1.) desirable and 2.) doable
The text was updated successfully, but these errors were encountered: