Documentation
¶
Overview ¶
Package collections provides generic filtering and searching utilities for filterable and named items.
Index ¶
- func FilterMap[T models.NamedFilterable](g map[string][]T, key *string, name *string, filter string, pred func(T) bool) map[string][]T
- func FilterMapOrAll[T models.NamedFilterable](g map[string][]T, filter string) map[string][]T
- func FilterSlice[T models.NamedFilterable](items []T, name *string, filter string, pred func(T) bool) []T
- func FindByName[T models.NamedItem](items []T, name string) *T
- func IsMatch(item models.Filterable, filter string, ignoreCase bool) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterMap ¶
func FilterMap[T models.NamedFilterable]( g map[string][]T, key *string, name *string, filter string, pred func(T) bool, ) map[string][]T
FilterMap returns a map of filtered items from the input map, filtered by key, name, filter, and an optional predicate.
func FilterMapOrAll ¶ added in v0.2.0
func FilterMapOrAll[T models.NamedFilterable](g map[string][]T, filter string) map[string][]T
FilterMapOrAll returns g unchanged when filter is empty, and a filtered copy otherwise. Useful for the common case where callers want "all rows when no filter is set" without conditional plumbing at every callsite.
func FilterSlice ¶
func FilterSlice[T models.NamedFilterable](items []T, name *string, filter string, pred func(T) bool) []T
FilterSlice returns a slice of items that match the filter and name. If pred is non-nil, the item must also satisfy pred(item).
func FindByName ¶
FindByName returns a pointer to the item with the given name, or nil if not found.
Types ¶
This section is empty.