largest

package
v0.60.5 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 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]) Items

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

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

Jump to

Keyboard shortcuts

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