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
class QuadTree.SubTree<T extends Envelope> extends Object implements Serializable
Sub tree of a quad tree.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(RectangleAndPayload<T> e)
Add a RectangleAndPayload to this SubTree.void
clear()
Delete all objects stored in this SubTree.boolean
contains(RectangleAndPayload<T> o)
Determine if this SubTree contains a specific object.String
dump(String indent)
Dump a quad tree.Rectangle
getBoundingBox()
Retrieve the bounding box of this sub tree.Set<RectangleAndPayload<T>>
recursiveCollect(Rectangle rectangle)
Recursively collect all elements that intersect the given rectangle.(package private) boolean
recursiveContains(RectangleAndPayload<T> o)
Recursively search for a particular object.boolean
remove(RectangleAndPayload<T> o)
Remove a RectangleAndPayload from this SubTree.int
size()
Return the number of objects stored in and under this SubTree.String
toString()
String
toString(int expandDepth)
Return a textual representation of this quad tree up to the specified depth.
-
-
-
Method Detail
-
getBoundingBox
public final Rectangle 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
public boolean add(RectangleAndPayload<T> e)
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
public boolean remove(RectangleAndPayload<T> o)
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
public boolean contains(RectangleAndPayload<T> o)
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
boolean recursiveContains(RectangleAndPayload<T> o)
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
public Set<RectangleAndPayload<T>> recursiveCollect(Rectangle rectangle)
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
public String toString(int expandDepth)
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
-
-