tree

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHashFunc added in v1.10.0

func GetHashFunc[T any]() func(T) H128

GetHashFunc returns a cached hash function for type T.

func TypeKeyOf added in v1.10.0

func TypeKeyOf[T any]() uintptr

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.

func UseLHS

func UseLHS[T any](a, _ T) T

UseLHS returns its LHS arg.

func UseRHS

func UseRHS[T any](_, b T) T

UseRHS returns its RHS arg.

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

func NewBuilder[T any](int) *Builder[T]

func (*Builder[T]) Add

func (b *Builder[T]) Add(v T)

func (*Builder[T]) Borrow

func (b *Builder[T]) Borrow() Tree[T]

func (*Builder[T]) Count

func (b *Builder[T]) Count() int

func (*Builder[T]) Finish

func (b *Builder[T]) Finish() Tree[T]

func (Builder[T]) Format

func (b Builder[T]) Format(state fmt.State, verb rune)

func (*Builder[T]) Get

func (b *Builder[T]) Get(el T) *T

func (*Builder[T]) Remove

func (b *Builder[T]) Remove(v T)

func (Builder[T]) String

func (b Builder[T]) String() string

type CombineArgs

type CombineArgs[T any] struct {
	*EqArgs[T]
	// contains filtered or unexported fields
}

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 (*CombineArgs[T]) Flip

func (a *CombineArgs[T]) Flip() *CombineArgs[T]

type EqArgs

type EqArgs[T any] struct {
	NodeArgs
	EqHash[T]
	// contains filtered or unexported fields
}

func DefaultNPEqArgs

func DefaultNPEqArgs[T any]() *EqArgs[T]

DefaultNPEqArgs provides default equality with non-parallel behaviour.

func DefaultNPKeyEqArgs

func DefaultNPKeyEqArgs[T any]() *EqArgs[T]

func NewDefaultEqArgs

func NewDefaultEqArgs[T any](gauge depth.Gauge) *EqArgs[T]

NewDefaultEqArgs creates EqArgs using the default resolved hash and equality functions.

func NewDefaultKeyEqArgs

func NewDefaultKeyEqArgs[T any](gauge depth.Gauge) *EqArgs[T]

func NewEqArgs

func NewEqArgs[T any](gauge depth.Gauge, ops EqHash[T]) *EqArgs[T]

NewEqArgs creates EqArgs from an EqHash implementation.

type EqHash added in v1.10.0

type EqHash[T any] interface {
	Equal(a, b T) bool
	Hash(a T) H128
	FullHash() bool
}

EqHash provides equality and hashing operations for tree elements.

type H128 added in v1.9.0

type H128 struct {
	// contains filtered or unexported fields
}

func (H128) Hi added in v1.9.0

func (h H128) Hi() uintptr

func (H128) Lo added in v1.9.0

func (h H128) Lo() uintptr

func (H128) String added in v1.9.0

func (h H128) String() string

type Iterator added in v1.4.0

type Iterator[T any] interface {
	Next() bool
	Value() T
}

Iterator provides for iterating over a Set.

func Empty added in v1.4.0

func Empty[T any]() Iterator[T]

Empty is the empty iterator.

type Less

type Less[T any] func(a, b T) bool

Less dictates the order of two elements.

type NodeArgs

type NodeArgs struct {
	depth.Gauge
}

func NewNodeArgs

func NewNodeArgs(gauge depth.Gauge) NodeArgs

type Tree

type Tree[T any] struct {
	// contains filtered or unexported fields
}

func Map added in v1.5.0

func Map[T, U any](t Tree[T], f func(v T) U) (out Tree[U])

func (Tree[T]) Combine

func (t Tree[T]) Combine(args *CombineArgs[T], u Tree[T]) (out Tree[T])

func (Tree[T]) Count

func (t Tree[T]) Count() int

func (Tree[T]) Difference

func (t Tree[T]) Difference(args *EqArgs[T], u Tree[T]) (out Tree[T])

func (Tree[T]) Equal

func (t Tree[T]) Equal(args *EqArgs[T], u Tree[T]) bool

func (Tree[T]) Format

func (t Tree[T]) Format(f fmt.State, verb rune)

func (Tree[T]) Gauge

func (t Tree[T]) Gauge() depth.Gauge

func (Tree[T]) Get

func (t Tree[T]) Get(v T) *T

func (Tree[T]) H0 added in v1.9.0

func (t Tree[T]) H0() H128

func (Tree[T]) Intersection

func (t Tree[T]) Intersection(args *EqArgs[T], u Tree[T]) (out Tree[T])

func (Tree[T]) Iterator

func (t Tree[T]) Iterator() Iterator[T]

func (Tree[T]) OrderedIterator

func (t Tree[T]) OrderedIterator(less Less[T], n int) Iterator[T]

func (Tree[T]) Reduce

func (t Tree[T]) Reduce(args NodeArgs, r func(values ...T) T) (_ T, _ bool)

func (Tree[T]) String

func (t Tree[T]) String() string

func (Tree[T]) SubsetOf

func (t Tree[T]) SubsetOf(args *EqArgs[T], u Tree[T]) bool

func (Tree[T]) Vet

func (t Tree[T]) Vet()

func (Tree[T]) Where

func (t Tree[T]) Where(args *WhereArgs[T]) (out Tree[T])

func (Tree[T]) With

func (t Tree[T]) With(v T) (out Tree[T])

func (Tree[T]) Without

func (t Tree[T]) Without(v T) (out Tree[T])

type WhereArgs

type WhereArgs[T any] struct {
	NodeArgs

	Pred func(elem T) bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL