Documentation ¶
Index ¶
- func Bounds(points ...[]float64) [][]float64
- func Contains(a, b Set) bool
- func Disjoint(a, b Set) bool
- func InvertSort(values []int) []int
- func Within(d1, d2, e float64) bool
- type BBGrid
- type BBNode
- func (bn *BBNode) Contains(pt []float64) bool
- func (bn *BBNode) Decompose(id int, bb [][]float64)
- func (bn *BBNode) Flatten() [][][]float64
- func (bn *BBNode) Intersection(bb [][]float64) [][]float64
- func (bn *BBNode) Leaves() [][][]float64
- func (bn *BBNode) Search(pt []float64, path []*BBNode) []*BBNode
- type BBTree
- type BRRow
- type Bits
- type KDNode
- type KDTree
- func (t *KDTree) Balance()
- func (t *KDTree) DNN(pt []float64, d float64) ([][]float64, []float64, []int)
- func (t *KDTree) InOrderPoints() [][]float64
- func (t *KDTree) Insert(pt []float64) int
- func (t *KDTree) KNN(pt []float64, k int) ([][]float64, []float64, []int)
- func (t *KDTree) Points() [][]float64
- func (t *KDTree) RemoveById(id int) bool
- func (t *KDTree) RemoveByPoint(pt []float64) bool
- func (t *KDTree) String() string
- type PointGrid
- func (g *PointGrid) Add(p []float64) (int, int, error)
- func (g *PointGrid) AdjacentCells(row, column int) [][]float64
- func (g *PointGrid) Cell(row, column int) [][]float64
- func (g *PointGrid) Len() int
- func (g *PointGrid) Location(p []float64) (int, int, error)
- func (g *PointGrid) NearestPoint(p []float64) ([]float64, float64, error)
- type PriorityItem
- type PriorityList
- type Set
- func (s Set) Add(e int) bool
- func (s Set) Contains(b Set) bool
- func (s Set) Copy() Set
- func (s Set) Difference(b Set) Set
- func (s Set) Disjoint(b Set) bool
- func (s Set) Element(e int) bool
- func (s Set) Empty() bool
- func (s Set) Intersection(b Set) Set
- func (s Set) Len() int
- func (s Set) Purge()
- func (s Set) Remove(e int) bool
- func (s Set) Slice() []int
- func (s Set) String() string
- func (s Set) Sub(b Set) Set
- func (s Set) Union(b Set) Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InvertSort ¶
InvertSort returns the list of switches that need to be made to render a list of integers into a sorted one.
Types ¶
type BBGrid ¶
type BBNode ¶
func (*BBNode) Intersection ¶
Find the bounding box of the intersection of bb with bn.BBox
type BRRow ¶
type BRRow struct { Columns int // Columns across Min, Max float64 // Bounds of the space // contains filtered or unexported fields }
Bounded region row, like BBGrid but for 1D regions
type Bits ¶
type Bits []uint64
Bits contains a compact representation of booleans in a uint64.
func BitsFromSlice ¶
BitsFromSlice returns Bits initialized with the contents of the boolean slice
type KDTree ¶
func (*KDTree) DNN ¶
Find all points within d of pt. Note d must in in the same space as the Dist function
func (*KDTree) InOrderPoints ¶
func (*KDTree) KNN ¶
Find up to k nearest points to pt Returns points, distances, indices to kdnodes
func (*KDTree) RemoveById ¶
func (*KDTree) RemoveByPoint ¶
Poor man's expensive
type PointGrid ¶
type PointGrid struct {
Rows, Columns int // Grid cells down and across
Min, Max []float64 // Bounds of the space
Wrap bool // Whether points should be wrapped in Min, Max
// contains filtered or unexported fields
}
PointGrid provides a simple way of finding points that are close to eachother.
func NewPointGrid ¶
NewPointGrid creates a new PointGrid with the supplied attributes.
func (*PointGrid) AdjacentCells ¶
AdjacentCells returns the points of the cell and the cells adjacent to it.
func (*PointGrid) NearestPoint ¶
NearestPoint looks in the cell containing the point and adjacent cells for the closest point. Returns the point (if any) and its distance or an error. A very poor implementation of nearest neighbor.
type PriorityItem ¶
PriorityItem contains the priority value and an id.
type PriorityList ¶
type PriorityList []PriorityItem
PriorityList holds the prioritized list of items. The lower the priority, the closer to the start of the list the item is.
func NewPriorityList ¶
func NewPriorityList(items ...PriorityItem) *PriorityList
NewPriorityList creates a new PriorityList with the items inserted. Lower values are inserted before higher ones.
func (*PriorityList) Delete ¶
func (pq *PriorityList) Delete(v PriorityItem) bool
Delete removes the entry in the list with the item (if found) and returns true. If the item isn't then false is returned. The priority value in the item is used to find where the item occurs in the list.
func (*PriorityList) DeleteEntry ¶
func (pq *PriorityList) DeleteEntry(e int) bool
DeleteEntry removes an entry from the list, compacts it and returns true. If the entry is not in range then false is returned.
func (*PriorityList) DeleteId ¶
func (pq *PriorityList) DeleteId(id int) bool
DeleteId removes the entry in the list with the item id (if found) and returns true. If the id isn't found then false is returned. This function uses a linear scan to find the id.
func (*PriorityList) Insert ¶
func (pq *PriorityList) Insert(v PriorityItem) int
Insert inserts the item into the list at the correct point and returns that insertion point. Insertion is performed using a binary search and copy() for speed.
type Set ¶
Set represents a set of integer elements.
func Difference ¶
Difference returns a new set containing only the elements in either a or b but not in both (XOR).
func Intersection ¶
Intersection returns a new set containing the intersection of a and b (AND).
func (Set) Add ¶
Add adds the element e to the set and returns true if it wasn't already in the set. Adding an element when it already exists is a no-op signified by false.
func (Set) Difference ¶
Difference returns a new set containing only the elements in either the set or b but not in both (XOR).
func (Set) Intersection ¶
Intersection returns a new set containing the intersection of the set and b (AND).
func (Set) Remove ¶
Remove removes element e from the set, if it exists by setting it to false, and returns true if it was in the set. Removing a non-existent element is a no-op signified by false. Use Purge() to actually shrink the set.