Package VASSAL.tools.qtree
Class QuadTree<T>
java.lang.Object
VASSAL.tools.qtree.QuadTree<T>
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
VassalMapQuadTree
Datastructure: A point Quad Tree for representing 2D data. Each
region has the same ratio as the bounds for the tree.
The implementation currently requires pre-determined bounds for data as it
can not rebalance itself to that degree.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all items from the tree.clone()
Clones the quad-tree and returns the new instance.boolean
contains
(double x, double y) Returns true if the point at (x, y) exists in the tree.Finds a leaf node with the same (x, y) coordinates as the target point, or null if no point exists.Gets the value of the point at (x, y) or null if the point is empty.int
getCount()
getKeys()
Returns an array containing the coordinates of each point stored in the tree.Returns a reference to the tree's root node.Returns a list containing all values stored within the tree.boolean
isEmpty()
void
remove
(double x, double y) Removes a point from (x, y) if it exists.searchIntersect
(double xmin, double ymin, double xmax, double ymax) searchWithin
(double xmin, double ymin, double xmax, double ymax) void
Sets the value of an (x, y) point within the quad-tree.void
setRootNode
(QNode<T> root) void
Traverses the tree depth-first, with quadrants being traversed in clockwise order (NE, SE, SW, NW).
-
Constructor Details
-
QuadTree
public QuadTree(double minX, double minY, double maxX, double maxY) Constructs a new quad tree. -
QuadTree
public QuadTree()
-
-
Method Details
-
getRootNode
-
setRootNode
-
set
Sets the value of an (x, y) point within the quad-tree. -
get
-
remove
Removes a point from (x, y) if it exists.- Returns:
- {T} The value of the node that was removed, or null if the node doesn't exist.
-
contains
public boolean contains(double x, double y) Returns true if the point at (x, y) exists in the tree.- Returns:
- {boolean} Whether the tree contains a point at (x, y).
-
isEmpty
public boolean isEmpty()- Returns:
- {boolean} Whether the tree is empty.
-
getCount
public int getCount()- Returns:
- {number} The number of items in the tree.
-
clear
public void clear()Removes all items from the tree. -
getKeys
-
getValues
-
searchIntersect
-
searchWithin
-
clone
-
traverse
-
find
-