Documentation ¶
Index ¶
- func BoxDist[N numeric, T any](targetMin, targetMax [2]N, itemDist func(min, max [2]N, data T) N) (dist func(min, max [2]N, data T, item bool) N)
- type Generic
- type RTree
- func (tr *RTree) Bounds() (min, max [2]float64)
- func (tr *RTree) Children(parent interface{}, reuse []child.Child) (children []child.Child)
- func (tr *RTree) Clear()
- func (tr *RTree) Copy() *RTree
- func (tr *RTree) Delete(min, max [2]float64, data interface{})
- func (tr *RTree) Insert(min, max [2]float64, data interface{})
- func (tr *RTree) Len() int
- func (tr *RTree) Nearby(algo func(min, max [2]float64, data interface{}, item bool) (dist float64), ...)
- func (tr *RTree) Replace(oldMin, oldMax [2]float64, oldData interface{}, newMin, newMax [2]float64, ...)
- func (tr *RTree) Scan(iter func(min, max [2]float64, data interface{}) bool)
- func (tr *RTree) Search(min, max [2]float64, iter func(min, max [2]float64, data interface{}) bool)
- type RTreeG
- func (tr *RTreeG[T]) Bounds() (min, max [2]float64)
- func (tr *RTreeG[T]) Clear()
- func (tr *RTreeG[T]) Copy() *RTreeG[T]
- func (tr *RTreeG[T]) Delete(min, max [2]float64, data T)
- func (tr *RTreeG[T]) Insert(min, max [2]float64, data T)
- func (tr *RTreeG[T]) Len() int
- func (tr *RTreeG[T]) Nearby(dist func(min, max [2]float64, data T, item bool) float64, ...)
- func (tr *RTreeG[T]) Replace(oldMin, oldMax [2]float64, oldData T, newMin, newMax [2]float64, newData T)
- func (tr *RTreeG[T]) Scan(iter func(min, max [2]float64, data T) bool)
- func (tr *RTreeG[T]) Search(min, max [2]float64, iter func(min, max [2]float64, data T) bool)
- type RTreeGN
- func (tr *RTreeGN[N, T]) BottomMost() (min, max [2]N, data T)
- func (tr *RTreeGN[N, T]) Bounds() (min, max [2]N)
- func (tr *RTreeGN[N, T]) Clear()
- func (tr *RTreeGN[N, T]) Copy() *RTreeGN[N, T]
- func (tr *RTreeGN[N, T]) Delete(min, max [2]N, data T)
- func (tr *RTreeGN[N, T]) Insert(min, max [2]N, data T)
- func (tr *RTreeGN[N, T]) LeftMost() (min, max [2]N, data T)
- func (tr *RTreeGN[N, T]) Len() int
- func (tr *RTreeGN[N, T]) Nearby(dist func(min, max [2]N, data T, item bool) float64, ...)
- func (tr *RTreeGN[N, T]) Replace(oldMin, oldMax [2]N, oldData T, newMin, newMax [2]N, newData T)
- func (tr *RTreeGN[N, T]) RightMost() (min, max [2]N, data T)
- func (tr *RTreeGN[N, T]) Scan(iter func(min, max [2]N, data T) bool)
- func (tr *RTreeGN[N, T]) Search(min, max [2]N, iter func(min, max [2]N, data T) bool)
- func (tr *RTreeGN[N, T]) TopMost() (min, max [2]N, data T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RTree ¶
type RTree struct {
// contains filtered or unexported fields
}
func (*RTree) Children ¶ added in v1.0.0
Children returns all children for parent node. If parent node is nil then the root nodes should be returned. The reuse buffer is an empty length slice that can optionally be used to avoid extra allocations.
func (*RTree) Copy ¶ added in v1.6.0
Copy the tree. This is a copy-on-write operation and is very fast because it only performs a shadowed copy.
func (*RTree) Nearby ¶ added in v0.9.0
func (tr *RTree) Nearby( algo func(min, max [2]float64, data interface{}, item bool) (dist float64), iter func(min, max [2]float64, data interface{}, dist float64) bool, )
Nearby performs a kNN-type operation on the index. It's expected that the caller provides its own the `dist` function, which is used to calculate a distance to rectangles and data. The `iter` function will return all items from the smallest distance to the largest distance.
BoxDist is included with this package for simple box-distance calculations. For example, say you want to return the closest items to Point(10 20):
tr.Nearby( rtree.BoxDist([2]float64{10, 20}, [2]float64{10, 20}, nil), func(min, max [2]float64, data int, dist float64) bool { return true }, )
func (*RTree) Replace ¶ added in v1.2.0
func (tr *RTree) Replace( oldMin, oldMax [2]float64, oldData interface{}, newMin, newMax [2]float64, newData interface{}, )
Replace an item in the structure. This is effectively just a Delete followed by an Insert. But for some structures it may be possible to optimize the operation to avoid multiple passes
type RTreeG ¶ added in v1.6.1
type RTreeG[T any] struct { // contains filtered or unexported fields }
func (*RTreeG[T]) Copy ¶ added in v1.6.1
Copy the tree. This is a copy-on-write operation and is very fast because it only performs a shadowed copy.
func (*RTreeG[T]) Nearby ¶ added in v1.8.0
func (tr *RTreeG[T]) Nearby( dist func(min, max [2]float64, data T, item bool) float64, iter func(min, max [2]float64, data T, dist float64) bool, )
Nearby performs a kNN-type operation on the index. It's expected that the caller provides its own the `dist` function, which is used to calculate a distance to rectangles and data. The `iter` function will return all items from the smallest distance to the largest distance.
BoxDist is included with this package for simple box-distance calculations. For example, say you want to return the closest items to Point(10 20):
tr.Nearby( rtree.BoxDist([2]float64{10, 20}, [2]float64{10, 20}, nil), func(min, max [2]float64, data int, dist float64) bool { return true }, )
func (*RTreeG[T]) Replace ¶ added in v1.6.1
func (tr *RTreeG[T]) Replace( oldMin, oldMax [2]float64, oldData T, newMin, newMax [2]float64, newData T, )
Replace an item. If the old item does not exist then the new item is not inserted.
type RTreeGN ¶ added in v1.9.0
type RTreeGN[N numeric, T any] struct { // contains filtered or unexported fields }
func (*RTreeGN[N, T]) BottomMost ¶ added in v1.9.1
func (tr *RTreeGN[N, T]) BottomMost() (min, max [2]N, data T)
func (*RTreeGN[N, T]) Bounds ¶ added in v1.9.0
func (tr *RTreeGN[N, T]) Bounds() (min, max [2]N)
Bounds returns the minimum bounding rect
func (*RTreeGN[N, T]) Clear ¶ added in v1.9.0
func (tr *RTreeGN[N, T]) Clear()
Clear will delete all items.
func (*RTreeGN[N, T]) Copy ¶ added in v1.9.0
Copy the tree. This is a copy-on-write operation and is very fast because it only performs a shadowed copy.
func (*RTreeGN[N, T]) Delete ¶ added in v1.9.0
func (tr *RTreeGN[N, T]) Delete(min, max [2]N, data T)
Delete data from tree
func (*RTreeGN[N, T]) Insert ¶ added in v1.9.0
func (tr *RTreeGN[N, T]) Insert(min, max [2]N, data T)
Insert data into tree
func (*RTreeGN[N, T]) LeftMost ¶ added in v1.9.1
func (tr *RTreeGN[N, T]) LeftMost() (min, max [2]N, data T)
func (*RTreeGN[N, T]) Nearby ¶ added in v1.9.0
func (tr *RTreeGN[N, T]) Nearby( dist func(min, max [2]N, data T, item bool) float64, iter func(min, max [2]N, data T, dist float64) bool, )
Nearby performs a kNN-type operation on the index. It's expected that the caller provides its own the `dist` function, which is used to calculate a distance to rectangles and data. The `iter` function will return all items from the smallest distance to the largest distance.
BoxDist is included with this package for simple box-distance calculations. For example, say you want to return the closest items to Point(10 20):
tr.Nearby( rtree.BoxDist([2]float64{10, 20}, [2]float64{10, 20}, nil), func(min, max [2]float64, data int, dist float64) bool { return true }, )
func (*RTreeGN[N, T]) Replace ¶ added in v1.9.0
func (tr *RTreeGN[N, T]) Replace( oldMin, oldMax [2]N, oldData T, newMin, newMax [2]N, newData T, )
Replace an item. If the old item does not exist then the new item is not inserted.
func (*RTreeGN[N, T]) RightMost ¶ added in v1.9.1
func (tr *RTreeGN[N, T]) RightMost() (min, max [2]N, data T)