Documentation
¶
Index ¶
- func GetHashFunc[T any]() func(T) H128
- func GetSeededHashFunc[T any]() func(T, uintptr) uintptr
- func TypeKeyOf[T any]() uintptr
- func UseLHS[T any](a, _ T) T
- func UseRHS[T any](_, b T) T
- type Builder
- type CombineArgs
- func CachedNPCombineArgs[T any]() *CombineArgs[T]
- func DefaultNPCombineArgs[T any]() *CombineArgs[T]
- func DefaultNPKeyCombineArgs[T any]() *CombineArgs[T]
- func NewCombineArgs[T any](ea *EqArgs[T], combine func(a, b T) T) *CombineArgs[T]
- func NewCombineArgsWithSame[T any](ea *EqArgs[T], combine func(a, b T) T, same func(a, b T) bool) *CombineArgs[T]
- type EqArgs
- type EqHash
- type H128
- type Iterator
- type Less
- type NodeArgs
- type Tree
- func (t Tree[T]) Combine(args *CombineArgs[T], u Tree[T]) (out Tree[T])
- func (t Tree[T]) Count() int
- func (t Tree[T]) Difference(args *EqArgs[T], u Tree[T]) (out Tree[T])
- func (t Tree[T]) Equal(args *EqArgs[T], u Tree[T]) bool
- func (t Tree[T]) Format(f fmt.State, verb rune)
- func (t Tree[T]) Gauge() depth.Gauge
- func (t Tree[T]) Get(v T) *T
- func (t Tree[T]) GetWith(args *EqArgs[T], v T) *T
- func (t Tree[T]) H0() H128
- func (t Tree[T]) Intersection(args *EqArgs[T], u Tree[T]) (out Tree[T])
- func (t Tree[T]) Iterator() Iterator[T]
- func (t Tree[T]) OrderedIterator(less Less[T], n int) Iterator[T]
- func (t Tree[T]) Reduce(args NodeArgs, r func(values ...T) T) (_ T, _ bool)
- func (t Tree[T]) String() string
- func (t Tree[T]) SubsetOf(args *EqArgs[T], u Tree[T]) bool
- func (t Tree[T]) Vet()
- func (t Tree[T]) Where(args *WhereArgs[T]) (out Tree[T])
- func (t Tree[T]) With(v T) (out Tree[T])
- func (t Tree[T]) WithWith(args *CombineArgs[T], v T) (out Tree[T])
- func (t Tree[T]) Without(v T) (out Tree[T])
- func (t Tree[T]) WithoutWith(args *EqArgs[T], v T) (out Tree[T])
- type WhereArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHashFunc ¶ added in v1.10.0
GetHashFunc returns a cached hash function for type T.
func GetSeededHashFunc ¶ added in v1.11.0
GetSeededHashFunc returns a cached seeded hash function for type T.
func TypeKeyOf ¶ added in v1.10.0
TypeKeyOf returns a uintptr that uniquely identifies the type T, suitable for use as a sync.Map key. It extracts the type-descriptor word from an eface wrapping *T, which is a compile-time constant. Using uintptr instead of reflect.Type avoids the expensive nilinterhash→typehash chain that sync.Map incurs when hashing interface keys.
Types ¶
type Builder ¶
type Builder[T any] struct { // contains filtered or unexported fields }
Builder[T] provides a more efficient way to build nodes incrementally.
func NewBuilder ¶
type CombineArgs ¶
func CachedNPCombineArgs ¶ added in v1.12.0
func CachedNPCombineArgs[T any]() *CombineArgs[T]
CachedNPCombineArgs returns a cached default CombineArgs with non-parallel behaviour and same set to the type's equality function. Suitable for Set.With where Equal is full equality and identical elements should not cause allocation.
func DefaultNPCombineArgs ¶
func DefaultNPCombineArgs[T any]() *CombineArgs[T]
DefaultNPCombineArgs provides default combiner with non-parallel behaviour.
func DefaultNPKeyCombineArgs ¶
func DefaultNPKeyCombineArgs[T any]() *CombineArgs[T]
func NewCombineArgs ¶
func NewCombineArgs[T any](ea *EqArgs[T], combine func(a, b T) T) *CombineArgs[T]
func NewCombineArgsWithSame ¶ added in v1.12.0
func NewCombineArgsWithSame[T any](ea *EqArgs[T], combine func(a, b T) T, same func(a, b T) bool) *CombineArgs[T]
NewCombineArgsWithSame creates CombineArgs with a full-equality check for no-op detection. Use this when Equal is weaker than structural equality (e.g. Map's key-only equality).
func (*CombineArgs[T]) Flip ¶
func (a *CombineArgs[T]) Flip() *CombineArgs[T]
Flip returns the arguments with the combining function's operands reversed. The pair is built when the arguments are constructed, not on first use: Combine runs on several goroutines once a tree is large enough to fan out, and a lazily assigned field would be a data race between them.
type EqArgs ¶
func DefaultNPEqArgs ¶
DefaultNPEqArgs provides default equality with non-parallel behaviour. The result is cached per type T since Gauge is a constant (NonParallel = -1) and EqArgs is read-only during Get/Without.
func DefaultNPKeyEqArgs ¶
func NewDefaultEqArgs ¶
NewDefaultEqArgs creates EqArgs using the default resolved hash and equality functions.
type H128 ¶ added in v1.9.0
type H128 struct {
// contains filtered or unexported fields
}
type NodeArgs ¶
func NewNodeArgs ¶
type Tree ¶
type Tree[T any] struct { // contains filtered or unexported fields }
func (Tree[T]) GetWith ¶ added in v1.11.0
GetWith is like Get but accepts pre-built EqArgs, avoiding the per-call allocation of DefaultNPEqArgs.
func (Tree[T]) Intersection ¶
func (Tree[T]) WithWith ¶ added in v1.12.0
func (t Tree[T]) WithWith(args *CombineArgs[T], v T) (out Tree[T])
WithWith is like With but uses pre-built CombineArgs, avoiding per-call allocation of equality/hash functions and enabling no-op detection via CombineArgs.same.
func (Tree[T]) WithoutWith ¶ added in v1.11.0
WithoutWith is like Without but accepts pre-built EqArgs, avoiding the per-call allocation of DefaultNPEqArgs.