Import std.collections.spatial
QuadTree
class
@DebugElements Public Class QuadTree<T> Implements Iterable<T>, Cloneable
Values at 2D points, in bounds it splits in four where points crowd.
Examples
Local tree = QuadTree<Int>(0, 0, 100, 100)
tree.Add(1, 10, 10)
tree.Add(2, 20, 20)
tree.Add(3, 60, 60)
Expect(tree.Query(0, 0, 25, 25).Count == 2)
Expect(tree.Move(1, 10, 10, 90, 5))
Expect(tree.Query(0, 0, 25, 25) == [2])std/collections/spatial.fb, line 561
-
An empty QuadTree for the points in the box from (
minX,minY) to (maxX,maxY), which has to be finite. A box whose max is below its min along an axis panics. -
How many values it holds.
-
Adds the
valueat (x,y). A point outside the QuadTree's box panics. -
Removes the first
valueequal tovalueat (x,y), and tells whether there was one. -
Whether a value equal to
valueis at (x,y). -
@PanicsAtCaller Public Method Move(value: T, x: Float, y: Float, toX: Float, toY: Float): Boolmethod #Moves the first
valueequal tovalueat (x,y) to (toX,toY), and tells whether there was one. A point outside the QuadTree's box panics. -
Takes every value out.
-
@PanicsAtCaller Public Method Query(minX: Float, minY: Float, maxX: Float, maxY: Float): T[]method #The values in the box from (
minX,minY) to (maxX,maxY), in a new array. -
The values no more than
radiusfrom (x,y), in a new array. -
Every value, in a new array.
-
A new QuadTree with the same box and values at the same points.
-
Every value. Adding or removing one while going over them panics.
Report an issue with this page or with FutureBlitz on GitHub.