四叉数之Box索引Point
来源:互联网 发布:dijkstra算法 有向图 编辑:程序博客网 时间:2024/06/08 11:53
上接第一篇四叉数之Box索引Box,以下源码如题。
这种情况貌似,再Node节点中在存一份Box更好。索引效率应该更高。
// box 索引 点的情况public class QuadTreePoint<T> { private Node<T> root; public static class Node<T> { public double x, y; public Node<T> NW, NE, SE, SW; public T s; public Node(double x, double y, T s) { this.x = x; this.y = y; this.s = s; } } public static class Box { private double xLow, xHigh, yLow, yHigh; public Box(double xLow, double xHigh, double yLow, double yHigh) { this.xLow = xLow; this.xHigh = xHigh; this.yLow = yLow; this.yHigh = yHigh; } public boolean contain(double x, double y) { return (x <= xHigh && x >= xLow && y <= yHigh && y >= yLow); } } public Node<T> insert(Node<T> node, double x, double y, T s) { if (node == null) { return new Node<T>(x, y, s); } if (x < node.x && y < node.y) { node.NW = insert(node.NW, x, y, s); return node; } if (x < node.x && !(y < node.y)) { node.SW = insert(node.SW, x, y, s); return node; } if (!(x < node.x) && y < node.y) { node.NE = insert(node.NE, x, y, s); return node; } if (!(x < node.x) && !(y < node.y)) { node.SE = insert(node.SE, x, y, s); } return null; } public List<Node<T>> query(Box box) { List<Node<T>> result = Lists.newArrayList(); query(root, box, result); return result; } private void query(Node<T> node, Box box, List<Node<T>> result) { if (node == null) { return; } if (box.contains(h.x, h.y)) result.add(h); if ( (box.xlow < h.x) && (box.ylow < h.y)) query(h.SW, box, result); if ( (box.xlow < h.x) && !(box.yhigh < h.y)) query(h.NW, box, result); if (!(box.xhigh < h.x) && (box.ylow < h.y)) query(h.SE, box, result); if (!(box.xhigh < h.x) && !(box.yhigh < h.y)) query(h.NE, box, result); }}
0 0
- 四叉数之Box索引Point
- 四叉数之box索引box
- Shader特效——“Point in Box”的实现 【GLSL】
- gxx_slide之Point Distance
- opengl之point
- System.Drawing之point
- C++之Point类
- 杭电之BOX
- CSS3之box-shadow
- CSS之box-shadow
- css3之box-shadow
- css之box模型
- box模型之margin
- CSS之Box-sizing
- threejs 中的Box的索引位置简介
- opencv3学习之Point类
- Point
- Point
- SQL Server 索引列的顺序——真的没关系吗
- 基于查找表的灰度拉伸
- 为你的Android App实现自签名的 SSL 证书
- ios webservice编程:soap封装调用,返回xml,json解析
- android setting的学习笔记
- 四叉数之Box索引Point
- 如何注册有价值的TOP域名
- 一段时间以来,我在思索一个问题:如何让别人知道你的产品?
- sql server 创建分区表
- 简单总结Service-与Activity生命周期
- source insight高速定位文件
- shell脚本监视进程
- 查询oracle中所有用户信息
- android 函数可变参数