largest

package
v0.66.3 Latest Latest
Warning

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

Go to latest
Published: Sep 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 Item

type Item[T any] struct {
	Value  T
	Weight float64
}

type Items

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

Items keeps track of a set of Items (with a Value and Weight), up to a fixed capacity, only retaining the highest weights (>= minMatch).

func NewItems

func NewItems[T any](capacity int, minMatch float64) *Items[T]

NewItems returns a structure which tracks the top-weighted Items, subject to minMatch and a fixed capacity.

func (*Items[T]) Add

func (xs *Items[T]) Add(it Item[T])

Add inserts an Item if it meets the minMatch threshold, ensuring we only keep the top N items by Weight.

func (*Items[T]) AddLocal added in v0.65.0

func (xs *Items[T]) AddLocal(it Item[T])

AddLocal is like Add but without locking. Safe only when a single goroutine owns the Items instance (e.g. a per-worker local top-K buffer).

func (*Items[T]) Items

func (xs *Items[T]) Items() []Item[T]

All returns a copy of all items in descending Weight order.

func (*Items[T]) Merge added in v0.65.0

func (xs *Items[T]) Merge(other *Items[T])

Merge incorporates all items from other into xs.

Jump to

Keyboard shortcuts

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