Import std.collections.spatial
SpatialHash
class
@DebugElements Public Class SpatialHash<T> Implements Iterable<T>, Cloneable
Values at 2D points, kept in square cells of a size, for things spread over a world of any size.
Examples
Local places = SpatialHash<String>(10)
places.Add("near", 3, 4)
places.Add("far", 100, 100)
Expect(places.Near(0, 0, 5) == ["near"])
Expect(places.Query(90, 90, 110, 110) == ["far"])std/collections/spatial.fb, line 116
-
An empty SpatialHash whose cells are
sizeacross, which has to be above 0 and finite. -
How many values it holds.
-
Adds the
valueat (x,y). -
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. -
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 SpatialHash with the same cells 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.