Package org.djutils.quadtree
Class QuadTree.SubTree<T extends Envelope>
java.lang.Object
org.djutils.quadtree.QuadTree.SubTree<T>
- Type Parameters:
T
- Type of object stored in this quad tree
- All Implemented Interfaces:
Serializable
Sub tree of a quad tree.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(RectangleAndPayload<T> e) Add a RectangleAndPayload to this SubTree.void
clear()
Delete all objects stored in this SubTree.boolean
Determine if this SubTree contains a specific object.Dump a quad tree.final Rectangle
Retrieve the bounding box of this sub tree.recursiveCollect
(Rectangle rectangle) Recursively collect all elements that intersect the given rectangle.(package private) boolean
Recursively search for a particular object.boolean
Remove a RectangleAndPayload from this SubTree.int
size()
Return the number of objects stored in and under this SubTree.toString()
toString
(int expandDepth) Return a textual representation of this quad tree up to the specified depth.
-
Constructor Details
-
SubTree
Construct a new sub tree.- Parameters:
root
- QuadTree<T>; the rootboundingBox
- Rectangle; the bounding box of the new sub tree
-
-
Method Details
-
getBoundingBox
Retrieve the bounding box of this sub tree.- Returns:
- Rectangle; the bounding box of this sub tree
-
size
public int size()Return the number of objects stored in and under this SubTree.- Returns:
- int; the number of objects stored in and under this SubTree
-
add
Add a RectangleAndPayload to this SubTree.- Parameters:
e
- RectangleAndPayload<T>; the object to add- Returns:
- boolean; true if this SubTree was changed (object was added); false if this SubTree did not change
-
remove
Remove a RectangleAndPayload from this SubTree.- Parameters:
o
- RectangleAndPayload<T>; the object to remove- Returns:
- boolean; true if this SubTree was changed (object was removed); false if this SubTree did not change
-
clear
public void clear()Delete all objects stored in this SubTree. -
contains
Determine if this SubTree contains a specific object.- Parameters:
o
- RectangleAndPayload<T>; the object to search- Returns:
- boolean; true if this SubTree contains the object
-
recursiveContains
Recursively search for a particular object.- Parameters:
o
- RectangleAndPayload<T>; the object to search for- Returns:
- boolean; true if this quad tree contains the object; false if this quad tree does not contain the object
-
recursiveCollect
Recursively collect all elements that intersect the given rectangle.- Parameters:
rectangle
- Rectangle; the rectangle- Returns:
- Set<RectangleAndPayload<T>>; all stored elements that intersect the given rectangle
-
toString
-
toString
Return a textual representation of this quad tree up to the specified depth.- Parameters:
expandDepth
- int; the maximum depth to expand- Returns:
- String; textual representation of this quad tree
-
dump
Dump a quad tree.- Parameters:
indent
- String; prefix for each output line- Returns:
- String; textual description of this quad tree.
-