|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--TreeJuxtaposer.RangeTree
A class representing a two-dimensional orthogonal range tree. RangeTree is a class that can answer range query in time (log n)^2. It implements the data structure of 2D range tree. Nodes of this tree are objects of type RangeNode.
RangeNode,
Tree2Tree,
AccordionDrawer.Tree,
AccordionDrawer.TreeNode| Field Summary | |
(package private) int |
element
|
(package private) RangeNode |
root
|
| Constructor Summary | |
RangeTree(Point[] A,
int dim)
Constructor: calls RangeTreeBuild to build the tree |
|
RangeTree(Tree treeA,
Tree treeB,
Tree2Tree t2t)
constructor: builds a 2D RangeTree data structure. |
|
| Method Summary | |
(package private) RangeNode |
build1D(Point[] A,
int start,
int end)
builds a 1D range tree using points from A[start] to A[end]. |
RangeNode |
build2D(Point[] A,
int start,
int end)
builds a 2D range tree using points from A[start] to A[end]. |
(package private) void |
Build2DRangeTree(Point[] A,
int dim)
|
private RangeNode |
findSplitRangeNode(int low,
int high)
Find a RangeNode with element in the range [low, high]. |
int |
getElement()
|
RangeNode |
getRoot()
|
boolean |
isEmpty()
|
static void |
mergeSort(Point[] A,
int dim)
This implements a regular merge sort algorithm. |
private static void |
ms_conq(Point[] A,
int start,
int mid,
int end,
int dim)
the conquer procedure merges two sorted parts together. |
private static void |
ms_divide(Point[] A,
int start,
int end,
int dim)
the divide procedure divides the array into two parts, sort them separately, and then merge the two sorted parts together. |
private int |
query1D(int ylow,
int yhigh)
the function queries in Y coordinate and return the total number of points in a given interval range. |
int |
query2D(int xlow,
int xhigh,
int ylow,
int yhigh)
Query2D returns the total number of points contained in the window [xlow, xhigh] X [ylow, yhigh]. |
private static int |
reportSubRangeTree(RangeNode l)
will report all the leaves decedant to RangeNode l. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
RangeNode root
int element
| Constructor Detail |
public RangeTree(Tree treeA,
Tree treeB,
Tree2Tree t2t)
treeA - the first treetreeB - the second treet2t - we're using the function getBestCorrNode of class Tree2Tree
public RangeTree(Point[] A,
int dim)
dim - dim = 0 represents a 2D range tree, dim = 1 represents a
1D range tree. This notation is not intuitive.A - an array of points| Method Detail |
void Build2DRangeTree(Point[] A,
int dim)
dim - dim = 0 represents a 2D range tree, dim = 1 represents a
1D range tree. This notation is not intuitive.A - an array of pointspublic boolean isEmpty()
public RangeNode getRoot()
public int getElement()
RangeNode build1D(Point[] A,
int start,
int end)
A - a list of pointsstart - the start position from array Aend - the end position from array A
public RangeNode build2D(Point[] A,
int start,
int end)
A - an array of pointsstart - the start position from the arrayend - the end position from the array
private RangeNode findSplitRangeNode(int low,
int high)
element in the range [low, high].
This function is used for query process.
low - the lowest value of the rangehigh - the highest value of the range
public int query2D(int xlow,
int xhigh,
int ylow,
int yhigh)
xlow - the leftmost value of x coordinatexhigh - the rightmost value of x coordinateylow - the lowest value of y coordinateyhigh - the highest value of y coordinate
private int query1D(int ylow,
int yhigh)
ylow - the lowest value of Y coordinateyhigh - the highest value of Y coordinate
query2D(int, int, int, int)private static int reportSubRangeTree(RangeNode l)
l.
This function is called during the query process when we find that
the whole subtree under l is contained in the query window.
l - should be 1D RangeNode
public static void mergeSort(Point[] A,
int dim)
A - an array to be sorteddim - the corresponding coordinate that sorting is based on
private static void ms_divide(Point[] A,
int start,
int end,
int dim)
A - the array to be sortedstart - the start position of the arrayend - the end position of the arraydim - the corresponding coordinate that sorting is based on
private static void ms_conq(Point[] A,
int start,
int mid,
int end,
int dim)
A - the array to be sortedstart - the start position of the arrayend - the end position of the arraymid - the mid valuedim - the corresponding coordinate that sorting is based on
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||