filter

package
v0.61.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterTypedMapCollection

func FilterTypedMapCollection[TItem any, TValue any](
	items []TItem,
	getMap func(TItem) *typedmap.ReadonlyTypedMap,
	filter TypedMapFilter[TValue],
) []TItem

FilterTypedMapCollection filters a collection of items using a type-safe filter TItem: the type of items being filtered TValue: the type of value being filtered on

Types

type ContainsElementFilter

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

ContainsElementFilter checks if a string array contains a specific element

func (*ContainsElementFilter) KeyToFilter

func (f *ContainsElementFilter) KeyToFilter() typedmap.TypedKey[[]string]

KeyToFilter implements TypedMapFilter interface

func (*ContainsElementFilter) ShouldInclude

func (f *ContainsElementFilter) ShouldInclude(found bool, values []string) bool

ShouldInclude implements TypedMapFilter interface

type EnabledFilter

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

EnabledFilter checks if a boolean value is true

func (*EnabledFilter) KeyToFilter

func (f *EnabledFilter) KeyToFilter() typedmap.TypedKey[bool]

KeyToFilter implements TypedMapFilter interface

func (*EnabledFilter) ShouldInclude

func (f *EnabledFilter) ShouldInclude(found bool, value bool) bool

ShouldInclude implements TypedMapFilter interface

type EqualFilter

type EqualFilter[T comparable] struct {
	// contains filtered or unexported fields
}

EqualFilter matches items with values exactly equal to the specified value

func (*EqualFilter[T]) KeyToFilter

func (f *EqualFilter[T]) KeyToFilter() typedmap.TypedKey[T]

KeyToFilter implements TypedMapFilter interface

func (*EqualFilter[T]) ShouldInclude

func (f *EqualFilter[T]) ShouldInclude(found bool, value T) bool

ShouldInclude implements TypedMapFilter interface

type TypedMapFilter

type TypedMapFilter[T any] interface {
	// KeyToFilter returns the key to evaluate
	KeyToFilter() typedmap.TypedKey[T]

	// ShouldInclude determines if an item should be included in filtered results
	// found: whether the key exists on the item
	// value: the value if it exists (zero value if found=false)
	ShouldInclude(found bool, value T) bool
}

TypedMapFilter is an interface for filtering objects that have a TypedMap Type parameter T represents the type of the value to filter on

func NewContainsElementFilter

func NewContainsElementFilter(key typedmap.TypedKey[[]string], element string, includeUndefined bool) TypedMapFilter[[]string]

NewContainsElementFilter creates a filter that checks if an array contains an element

func NewEnabledFilter

func NewEnabledFilter(key typedmap.TypedKey[bool], includeUndefined bool) TypedMapFilter[bool]

NewEnabledFilter creates a filter that checks if a boolean value is true

func NewEqualFilter

func NewEqualFilter[T comparable](key typedmap.TypedKey[T], value T, includeUndefined bool) TypedMapFilter[T]

NewEqualFilter creates a new filter that matches exact values

Jump to

Keyboard shortcuts

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