searchtypes

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitset64

type Bitset64 uint64

Bitset64 of types

func NewBitset64

func NewBitset64(types ...uint) (b Bitset64)

NewBitset64 from types

func (*Bitset64) Has

func (b *Bitset64) Has(t uint) bool

Has type in bitset

func (Bitset64) Numbers

func (b Bitset64) Numbers() (list []uint)

Numbers from bites

func (*Bitset64) Set

func (b *Bitset64) Set(types ...uint)

Set type values

func (*Bitset64) Unset

func (b *Bitset64) Unset(types ...uint)

Unset type values

type Integer

type Integer interface {
	~uint | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Integer type constraint for generic NumberBitset

type Node

type Node struct {
	ParentID uint64 // 0 = root
	ID       uint64
	Value    string // IAB code and/or name
}

Node is a tree entry for U64StringMatcher.

type NumberBitset

type NumberBitset[T Integer] struct {
	// contains filtered or unexported fields
}

NumberBitset any numbers

func NewNumberBitset

func NewNumberBitset[T Integer](vals ...T) (b *NumberBitset[T])

NewNumberBitset from numbers

func (*NumberBitset[T]) ContainsAllFrom

func (b *NumberBitset[T]) ContainsAllFrom(set *NumberBitset[T]) (res bool)

ContainsAllFrom items from the set

func (*NumberBitset[T]) Has

func (b *NumberBitset[T]) Has(v T) bool

Has type in bitset

func (*NumberBitset[T]) HasOneOf

func (b *NumberBitset[T]) HasOneOf(vals ...T) bool

HasOneOf reports whether the set contains any of vals.

func (*NumberBitset[T]) Len

func (b *NumberBitset[T]) Len() int

Len of the elements

func (*NumberBitset[T]) Mask

func (b *NumberBitset[T]) Mask() uint64

Mask of the set

func (*NumberBitset[T]) Reset

func (b *NumberBitset[T]) Reset() *NumberBitset[T]

Reset bitset value

func (*NumberBitset[T]) Set

func (b *NumberBitset[T]) Set(vals ...T) *NumberBitset[T]

Set type values

func (*NumberBitset[T]) Unset

func (b *NumberBitset[T]) Unset(vals ...T) *NumberBitset[T]

Unset type values

func (*NumberBitset[T]) Values

func (b *NumberBitset[T]) Values() []T

Values list

type ObjectBitset

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

ObjectBitset any numbers

func NewObjectBitset

func NewObjectBitset(cmp func(a, b any) int, value func(o1 any) uint, vals ...any) (b *ObjectBitset)

NewObjectBitset from numbers

func (*ObjectBitset) Has

func (b *ObjectBitset) Has(v any) bool

Has type in bitset

func (*ObjectBitset) HasOneOf

func (b *ObjectBitset) HasOneOf(vals ...any) bool

HasOneOf reports whether the set contains any of vals. Membership is the same == check as Has, not cmp == 0.

func (*ObjectBitset) Len

func (b *ObjectBitset) Len() int

Len of the elements

func (*ObjectBitset) Set

func (b *ObjectBitset) Set(vals ...any) *ObjectBitset

Set type values

func (*ObjectBitset) Unset

func (b *ObjectBitset) Unset(vals ...any) *ObjectBitset

Unset type values

func (*ObjectBitset) Values

func (b *ObjectBitset) Values() []any

Values list

type U64KeywordMatcher

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

U64KeywordMatcher maps keyword phrases to uint64 IDs with word-start prefix matching. Lifecycle: Set → Freeze → concurrent Match (no locks).

Matching: from each whitespace-delimited word start in the input, walk the trie. Intermediate phrase words must match exactly (then whitespace); the final phrase word may be a prefix of the input word (e.g. "racing" matches "racings"). Among hits, the longest normalized phrase wins; ties prefer the first word-start.

func NewU64KeywordMatcher

func NewU64KeywordMatcher() *U64KeywordMatcher

NewU64KeywordMatcher creates an empty matcher.

func (*U64KeywordMatcher) Freeze

func (m *U64KeywordMatcher) Freeze() *U64KeywordMatcher

Freeze seals the matcher into contiguous node/edge arenas for Match.

func (*U64KeywordMatcher) Match

func (m *U64KeywordMatcher) Match(input string) uint64

Match finds the best category ID for input, or 0.

func (*U64KeywordMatcher) Set

func (m *U64KeywordMatcher) Set(phrase string, id uint64) *U64KeywordMatcher

Set registers or overwrites a phrase → id mapping. Empty / whitespace-only phrases are skipped.

type U64StringMatcher

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

U64StringMatcher is a build-once string↔uint64 tree matcher (e.g. IAB categories). Lifecycle: Set / SetNodes → Freeze → concurrent Match* (no locks).

func NewU64StringMatcher

func NewU64StringMatcher() *U64StringMatcher

NewU64StringMatcher creates an empty matcher.

func (*U64StringMatcher) AllChildrenID

func (m *U64StringMatcher) AllChildrenID(id uint64) []uint64

AllChildrenID returns all descendant IDs of id (self not included). After Freeze the slice is internal/shared — do not mutate.

func (*U64StringMatcher) Freeze

func (m *U64StringMatcher) Freeze() *U64StringMatcher

Freeze seals the matcher and materializes full descendant ID lists.

func (*U64StringMatcher) MatchAllChildrenID

func (m *U64StringMatcher) MatchAllChildrenID(key string) []uint64

MatchAllChildrenID resolves key globally, then returns AllChildrenID of that node.

func (*U64StringMatcher) MatchCode

func (m *U64StringMatcher) MatchCode(id uint64) string

MatchCode returns the canonical Value for id, or "".

func (*U64StringMatcher) MatchID

func (m *U64StringMatcher) MatchID(id uint64, key string) uint64

MatchID finds key in the subtree rooted at id (id itself + all descendants). id == 0 searches the whole forest. Returns 0 if missing / outside subtree.

func (*U64StringMatcher) ParentID

func (m *U64StringMatcher) ParentID(id uint64) uint64

ParentID returns the parent of id (0 for roots / unknown).

func (*U64StringMatcher) Set

func (m *U64StringMatcher) Set(parentID, id uint64, value string) *U64StringMatcher

Set registers or overwrites a node under parentID (0 = root).

func (*U64StringMatcher) SetNodes

func (m *U64StringMatcher) SetNodes(nodes ...Node) *U64StringMatcher

SetNodes registers multiple nodes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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