Documentation
¶
Index ¶
- func AllValues[K Hashable, V comparable](c map[K]V, eq any) bool
- func Atoc(s string) uint8
- func Atof(s string) float64
- func Atoi(s string) int
- func Chunk[T any](list []T, size int) [][]T
- func Deref[T any](v *T) T
- func EuclideanMod[N constraints.Integer](n N, div N) N
- func FasterHash(data any) string
- func Filter[T any](list []T, fn func(a T) bool) []T
- func FindQuadraticCoefficients[N Number](y0, y1, y2 N) (N, N, N)
- func GCD(a, b int) int
- func HashedMemo[In any, Out any](f func(a In) Out, hashFn *func(data any) string, cache *map[string]Out) func(a In) Out
- func Hexi(s string) int
- func In(haystack string, chars string) bool
- func LCM(integers ...int) int
- func Manhattan[N Number](x1 N, y1 N, x2 N, y2 N) N
- func Map[T, R any](list []T, fn func(a T) R) []R
- func Map2[T, R any](list []T, fn func(a T, i int) R) []R
- func Memo[In comparable, Out any](f func(a In) Out, cache *map[In]Out) func(a In) Out
- func NonZero(i int) int
- func Octile[N Number](x1 N, y1 N, x2 N, y2 N) N
- func PicksInterior[N Number](area N, boundary N) N
- func Product[N Number](collection []N) N
- func Ptr[T any](v T) *T
- func Pythagoras[N Number](x1 N, y1 N, x2 N, y2 N) N
- func Reset[T any](c *[]T)
- func Shoelace[N Number](points []Point2D[N]) float64
- func SolveQuadratic[N Number](a, b, c, x N) N
- func Sqrt[N Number](x N) (z N)
- func Sum[N Number](collection []N) N
- type BucketQueue
- type Hashable
- type Number
- type Point2D
- type Queue
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EuclideanMod ¶
func EuclideanMod[N constraints.Integer](n N, div N) N
func FasterHash ¶
FasterHash takes any object and returns a hash string as fast as possible.
func FindQuadraticCoefficients ¶
func FindQuadraticCoefficients[N Number](y0, y1, y2 N) (N, N, N)
func HashedMemo ¶
func HashedMemo[In any, Out any]( f func(a In) Out, hashFn *func(data any) string, cache *map[string]Out, ) func(a In) Out
HashedMemo is a generic memoization function that hashes an incomparable argument.
func Memo ¶
func Memo[In comparable, Out any]( f func(a In) Out, cache *map[In]Out, ) func(a In) Out
Memo is a generic memoization function that accepts 1 comparable argument.
func PicksInterior ¶
func PicksInterior[N Number](area N, boundary N) N
func Pythagoras ¶
func Pythagoras[N Number](x1 N, y1 N, x2 N, y2 N) N
func SolveQuadratic ¶
func SolveQuadratic[N Number](a, b, c, x N) N
Types ¶
type BucketQueue ¶
type BucketQueue[V any] struct { Buckets []*deque.Deque[V] // contains filtered or unexported fields }
func NewBucketQueue ¶
func NewBucketQueue[V any](numBuckets int, bucketCapacity int) *BucketQueue[V]
func (*BucketQueue[V]) Pop ¶
func (q *BucketQueue[V]) Pop() (V, int)
func (*BucketQueue[V]) Push ¶
func (q *BucketQueue[V]) Push(prio int, v V)
func (*BucketQueue[V]) Size ¶
func (q *BucketQueue[V]) Size() int
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
type SearchResult ¶
type SearchResult[T any, W Number] struct { Best *T BestWeight W BestPath []*T Paths int Milliseconds int64 Iterations int }
func BucketSearch ¶
func BucketSearch[T any, H comparable, W Number]( root *T, branchFn func(branch *T) []*T, predicateFn func(branch *T) bool, hashFn func(branch *T) H, weightFn func(branch *T, parentWeight W) W, heuristicFn func(branch *T) W, priorityScale int, returnFirst bool, maximize bool, ) *SearchResult[T, W]
func IterativeSearch ¶
func IterativeSearch[T any, H comparable, W Number]( root *T, branchFn func(branch *T) []*T, predicateFn func(branch *T) bool, hashFn func(branch *T) H, weightFn func(branch *T, parentWeight W) W, heuristicFn func(branch *T) W, beamWidth int, returnFirst bool, maximize bool, ) *SearchResult[T, W]
Click to show internal directories.
Click to hide internal directories.