Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package sonc.quad;
  2.  
  3. import java.util.HashSet;
  4. import java.util.Set;
  5.  
  6. public class PointQuadtree<T extends HasPoint> extends java.lang.Object
  7. {
  8. Trie<T> root;
  9.  
  10. PointQuadtree(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY)
  11. {
  12. root = new LeafTrie<T>(topLeftX, topLeftY, bottomRightX, bottomRightY);
  13. }
  14.  
  15. public void delete(T point)
  16. {
  17. root.delete(point);
  18. }
  19.  
  20. public T find(T point)
  21. {
  22. return root.find(point);
  23. }
  24.  
  25. public Set<T> findNear(double x, double y, double radius)
  26. {
  27. Set<T> pointsInCircule = new HashSet<T>();
  28.  
  29. root.collectNear(x, y, radius, pointsInCircule);
  30.  
  31. return pointsInCircule;
  32.  
  33. }
  34.  
  35. public Set<T> getAll()
  36. {
  37. Set<T> pointsInTree = new HashSet<T>();
  38.  
  39. root.collectAll(pointsInTree);
  40.  
  41. return pointsInTree;
  42.  
  43. }
  44.  
  45. public void insert(T point)
  46. {
  47. root = root.insert(point);
  48. }
  49.  
  50. public void insertReplace(T point)
  51. {
  52. root = root.insertReplace(point);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement