Documentation
¶
Overview ¶
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
Index ¶
- func All(slice []bool) bool
- func AllFunc[S ~[]E, E any](s S, f func(E) bool) bool
- func AllNotEmpty(strict bool, slice []string) bool
- func AllSequence(seq iter.Seq[bool]) bool
- func AllTrue(values ...bool) bool
- func AllTrueSequence[E any](s iter.Seq[E], f func(E) bool) bool
- func And(values ...bool) bool
- func Any(slice []bool) bool
- func AnyEmpty(strict bool, slice []string) bool
- func AnyFalse(values ...bool) bool
- func AnyFalseSequence(eq iter.Seq[bool]) bool
- func AnyFunc[S ~[]E, E any](s S, f func(E) bool) bool
- func AnySequence(seq iter.Seq[bool]) bool
- func AnyTrue(values ...bool) bool
- func ConvertListOfPairsToMap(input []string, pairSeparator string) (pairs map[string]string, err error)
- func ConvertMapToCommaSeparatedList[K comparable, V any](pairs map[K]V) string
- func ConvertMapToCommaSeparatedPairsList[K comparable, V any](pairs map[K]V, pairSeparator string) string
- func ConvertMapToLoggerValues[K comparable, V any](pairs map[K]V) []any
- func ConvertMapToOrderedCommaSeparatedList[K cmp.Ordered, V any](pairs map[K]V) string
- func ConvertMapToOrderedSlice[K cmp.Ordered, V any](pairs map[K]V) []string
- func ConvertMapToPairSlice[K comparable, V any](pairs map[K]V, pairSeparator string) []string
- func ConvertMapToSlice[K comparable, V any](pairs map[K]V) []string
- func ConvertSliceToCommaSeparatedList[T any](slice []T) string
- func ConvertSliceToMap[T comparable](input []T) (pairs map[T]T, err error)
- func Difference[T comparable](slice1, slice2 []T) []T
- func Each[T any](s iter.Seq[T], f func(T) error) error
- func Filter[S ~[]E, E any](s S, f FilterFunc[E]) S
- func FilterSequence[E any](s iter.Seq[E], f Predicate[E]) (result iter.Seq[E])
- func Find(slice *[]string, val string) (int, bool)
- func FindInSequence[E any](elements iter.Seq[E], predicate Predicate[E]) (int, bool)
- func FindInSlice(strict bool, slice []string, val ...string) (int, bool)
- func ForEach[S ~[]E, E any](s S, f func(E))
- func ForEachValues[E any](f func(E), values ...E)
- func GenericRemove(equal func(string, string) bool, slice []string, val ...string) []string
- func Intersection[T comparable](slice1, slice2 []T) []T
- func Map[T1 any, T2 any](s []T1, f MapFunc[T1, T2]) []T2
- func MapSequence[T1 any, T2 any](s iter.Seq[T1], f MapFunc[T1, T2]) iter.Seq[T2]
- func MapSequenceWithError[T1 any, T2 any](s iter.Seq[T1], f MapWithErrorFunc[T1, T2]) iter.Seq[T2]
- func MapWithError[T1 any, T2 any](s []T1, f MapWithErrorFunc[T1, T2]) (result []T2, err error)
- func Match[E any](e E, matches ...FilterFunc[E]) bool
- func MatchAll[E any](e E, matches ...FilterFunc[E]) bool
- func Negate(values ...bool) []bool
- func OneHot(values ...bool) bool
- func Or(values ...bool) bool
- func ParseCommaSeparatedList(input string) []string
- func ParseCommaSeparatedListOfPairsToMap(input, pairSeparator string) (pairs map[string]string, err error)
- func ParseCommaSeparatedListToMap(input string) (pairs map[string]string, err error)
- func ParseListWithCleanup(input string, sep string) (newS []string)
- func ParseListWithCleanupKeepBlankLines(input string, sep string) (newS []string)
- func Range(start, stop int, step *int) []int
- func Reduce[T1, T2 any](s []T1, accumulator T2, f ReduceFunc[T1, T2]) T2
- func ReducesSequence[T1, T2 any](s iter.Seq[T1], accumulator T2, f ReduceFunc[T1, T2]) (result T2)
- func Reject[S ~[]E, E any](s S, f FilterFunc[E]) S
- func RejectSequence[E any](s iter.Seq[E], f FilterFunc[E]) iter.Seq[E]
- func Remove(slice []string, val ...string) []string
- func SymmetricDifference[T comparable](slice1, slice2 []T) []T
- func Union[T comparable](slice1, slice2 []T) []T
- func Unique[T comparable](s iter.Seq[T]) []T
- func UniqueEntries[T comparable](slice []T) []T
- func Xor(values ...bool) bool
- type Conditions
- func (c *Conditions) Add(conditions ...bool) Conditions
- func (c *Conditions) All() bool
- func (c *Conditions) And() bool
- func (c *Conditions) Any() bool
- func (c *Conditions) Concat(more *Conditions) Conditions
- func (c *Conditions) Contains(condition bool) bool
- func (c *Conditions) ForEach(each func(bool) error) error
- func (c *Conditions) Negate() Conditions
- func (c *Conditions) OneHot() bool
- func (c *Conditions) Or() bool
- func (c *Conditions) Xor() bool
- type FilterFunc
- type MapFunc
- type MapWithErrorFunc
- type Predicate
- type ReduceFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllFunc ¶ added in v1.78.0
AllFunc returns whether f returns true for all the elements of slice s.
func AllNotEmpty ¶ added in v1.49.0
AllNotEmpty returns whether all elements of the slice are not empty. If strict, then whitespaces are considered as empty strings
func AllSequence ¶ added in v1.134.0
AllSequence returns true if all items of the sequence are true.
func AllTrueSequence ¶ added in v1.134.0
AllTrueSequence returns whether f returns true for all the elements in a sequence.
func AnyEmpty ¶ added in v1.49.0
AnyEmpty returns whether there is one entry in the slice which is empty. If strict, then whitespaces are considered as empty strings
func AnyFalseSequence ¶ added in v1.134.0
AnyFalseSequence returns true if there is at least one element of the sequence which is false. If the sequence is empty, it also returns true.
func AnyFunc ¶ added in v1.78.0
AnyFunc returns whether there is at least one element of slice s for which f() returns true.
func AnySequence ¶ added in v1.134.0
AnySequence returns true if there is at least one element of the slice which is true.
func ConvertListOfPairsToMap ¶ added in v1.97.0
func ConvertMapToCommaSeparatedList ¶ added in v1.96.0
func ConvertMapToCommaSeparatedList[K comparable, V any](pairs map[K]V) string
ConvertMapToCommaSeparatedList converts a map to a string of comma separated list of keys and values defined sequentially
func ConvertMapToCommaSeparatedPairsList ¶ added in v1.96.0
func ConvertMapToCommaSeparatedPairsList[K comparable, V any](pairs map[K]V, pairSeparator string) string
ConvertMapToCommaSeparatedPairsList converts a map to a string of comma separated list of key, value pairs.
func ConvertMapToLoggerValues ¶ added in v1.116.0
func ConvertMapToLoggerValues[K comparable, V any](pairs map[K]V) []any
ConvertMapToLoggerValues is similar to ConvertMapToSlice but returns a type compatible with logr.Logger.
func ConvertMapToOrderedCommaSeparatedList ¶ added in v1.128.0
ConvertMapToOrderedCommaSeparatedList converts a map to a commar-separated list and ensures that the ordering will always be the same
func ConvertMapToOrderedSlice ¶ added in v1.128.0
ConvertMapToOrderedSlice converts a map to a slice and ensures that the ordering will always be the same
func ConvertMapToPairSlice ¶ added in v1.96.0
func ConvertMapToPairSlice[K comparable, V any](pairs map[K]V, pairSeparator string) []string
ConvertMapToPairSlice converts a map to list of key value pairs e.g. ["key1=value1", "key2=value2"]
func ConvertMapToSlice ¶ added in v1.96.0
func ConvertMapToSlice[K comparable, V any](pairs map[K]V) []string
ConvertMapToSlice converts a map to list of keys and values listed sequentially e.g. [key1, value1, key2, value2]
func ConvertSliceToCommaSeparatedList ¶ added in v1.96.0
ConvertSliceToCommaSeparatedList converts a slice into a string containing a coma separated list
func ConvertSliceToMap ¶ added in v1.97.0
func ConvertSliceToMap[T comparable](input []T) (pairs map[T]T, err error)
ConvertSliceToMap converts a slice of elements into a map e.g. [key1, value1, key2, values2] -> {key1: value1, key2: value2}
func Difference ¶ added in v1.134.0
func Difference[T comparable](slice1, slice2 []T) []T
Difference returns the Difference between slice1 and slice2 (only unique values are returned).
func Each ¶ added in v1.134.0
Each iterates over a sequence and executes the passed function against each element. If passed func returns an error, the iteration stops and the error is returned, unless it is EOF.
func Filter ¶ added in v1.110.0
func Filter[S ~[]E, E any](s S, f FilterFunc[E]) S
Filter returns a new slice that contains elements from the input slice which return true when they’re passed as a parameter to the provided filtering function f.
func FilterSequence ¶ added in v1.134.0
FilterSequence returns a new sequence that contains elements from the input sequence which return true when they’re passed as a parameter to the provided filtering function f.
func Find ¶
Find looks for an element in a slice. If found it will return its index and true; otherwise it will return -1 and false.
func FindInSequence ¶ added in v1.134.0
FindInSequence searches a collection for an element satisfying the predicate.
func FindInSlice ¶ added in v1.49.0
FindInSlice finds if any values val are present in the slice and if so returns the first index. if strict, it checks for an exact match; otherwise it discards whitespaces and case.
func ForEach ¶ added in v1.134.0
func ForEach[S ~[]E, E any](s S, f func(E))
ForEach iterates over elements and executes the passed function on each element.
func ForEachValues ¶ added in v1.134.0
func ForEachValues[E any](f func(E), values ...E)
ForEachValues iterates over values and executes the passed function on each of them.
func GenericRemove ¶ added in v1.4.0
GenericRemove looks for elements in a slice using the equal function. If they're found, it will remove them from the slice.
func Intersection ¶ added in v1.134.0
func Intersection[T comparable](slice1, slice2 []T) []T
Intersection returns the intersection of two slices (only unique values are returned).
func Map ¶ added in v1.110.0
Map creates a new slice and populates it with the results of calling the provided function on every element in input slice.
func MapSequence ¶ added in v1.134.0
MapSequence creates a new sequences and populates it with the results of calling the provided function on every element of the input sequence.
func MapSequenceWithError ¶ added in v1.134.0
MapSequenceWithError creates a new sequences and populates it with the results of calling the provided function on every element of the input sequence. If an error happens, the mapping stops.
func MapWithError ¶ added in v1.124.0
func MapWithError[T1 any, T2 any](s []T1, f MapWithErrorFunc[T1, T2]) (result []T2, err error)
MapWithError creates a new slice and populates it with the results of calling the provided function on every element in input slice. If an error happens, the mapping stops and the error returned.
func Match ¶ added in v1.127.0
func Match[E any](e E, matches ...FilterFunc[E]) bool
Match checks whether an element e matches any of the matching functions.
func MatchAll ¶ added in v1.127.0
func MatchAll[E any](e E, matches ...FilterFunc[E]) bool
MatchAll checks whether an element e matches all the matching functions.
func OneHot ¶ added in v1.80.0
OneHot returns true if one, and only one, of the supplied values is true. See https://en.wikipedia.org/wiki/One-hot
func ParseCommaSeparatedList ¶
ParseCommaSeparatedList returns the list of string separated by a comma
func ParseCommaSeparatedListOfPairsToMap ¶ added in v1.96.0
func ParseCommaSeparatedListOfPairsToMap(input, pairSeparator string) (pairs map[string]string, err error)
ParseCommaSeparatedListOfPairsToMap returns a map of key value pairs from a string containing a comma separated list of pairs using pairSeparator to separate between keys and values e.g. key1=value1,key2=value2
func ParseCommaSeparatedListToMap ¶ added in v1.71.0
ParseCommaSeparatedListToMap returns a map of key value pairs from a string containing a comma separated list
func ParseListWithCleanup ¶ added in v1.9.0
ParseListWithCleanup splits a string into a list like strings.Split but also removes any whitespace surrounding the different items for example, ParseListWithCleanup("a, b , c", ",") returns []{"a","b","c"}
func ParseListWithCleanupKeepBlankLines ¶ added in v1.12.0
ParseListWithCleanupKeepBlankLines splits a string into a list like strings.Split but also removes any whitespace surrounding the different items unless the entire item is whitespace in which case it is converted to an empty string. For example, ParseListWithCleanupKeepBlankLines("a, b , c", ",") returns []{"a","b","c"} ParseListWithCleanupKeepBlankLines("a, b , , c", ",") returns []{"a","b", "", "c"}
func Range ¶ added in v1.120.0
Range returns a slice of integers similar to Python's built-in range(). https://docs.python.org/2/library/functions.html#range
Note: The stop value is always exclusive.
func Reduce ¶ added in v1.110.0
func Reduce[T1, T2 any](s []T1, accumulator T2, f ReduceFunc[T1, T2]) T2
Reduce runs a reducer function f over all elements in the array, in ascending-index order, and accumulates them into a single value.
func ReducesSequence ¶ added in v1.134.0
func ReducesSequence[T1, T2 any](s iter.Seq[T1], accumulator T2, f ReduceFunc[T1, T2]) (result T2)
ReducesSequence runs a reducer function f over all elements of a sequence, in ascending-index order, and accumulates them into a single value.
func Reject ¶ added in v1.110.0
func Reject[S ~[]E, E any](s S, f FilterFunc[E]) S
Reject is the opposite of Filter and returns the elements of collection for which the filtering function f returns false. This is functionally equivalent to slices.DeleteFunc but it returns a new slice.
func RejectSequence ¶ added in v1.134.0
RejectSequence is the opposite of FilterSequence and returns the elements of collection for which the filtering function f returns false.
func Remove ¶ added in v1.4.0
Remove looks for elements in a slice. If they're found, it will remove them.
func SymmetricDifference ¶ added in v1.134.0
func SymmetricDifference[T comparable](slice1, slice2 []T) []T
SymmetricDifference returns the symmetric difference between slice1 and slice2 (only unique values are returned).
func Union ¶ added in v1.134.0
func Union[T comparable](slice1, slice2 []T) []T
Union returns the union of two slices (only unique values are returned).
func Unique ¶ added in v1.134.0
func Unique[T comparable](s iter.Seq[T]) []T
Unique returns all the unique values contained in a sequence.
func UniqueEntries ¶ added in v1.75.0
func UniqueEntries[T comparable](slice []T) []T
UniqueEntries returns all the unique values contained in a slice.
Types ¶
type Conditions ¶ added in v1.80.0
type Conditions []bool
func NewConditions ¶ added in v1.80.0
func NewConditions(capacity int) Conditions
NewConditions creates a set of conditions.
func NewConditionsFromValues ¶ added in v1.80.0
func NewConditionsFromValues(conditions ...bool) Conditions
NewConditionsFromValues creates a set of conditions.
func (*Conditions) Add ¶ added in v1.80.0
func (c *Conditions) Add(conditions ...bool) Conditions
Add adds conditions and returns itself.
func (*Conditions) All ¶ added in v1.80.0
func (c *Conditions) All() bool
All returns true if all conditions are true.
func (*Conditions) And ¶ added in v1.80.0
func (c *Conditions) And() bool
And performs an `and` operation on all conditions
func (*Conditions) Any ¶ added in v1.80.0
func (c *Conditions) Any() bool
Any returns true if there is at least one condition which is true.
func (*Conditions) Concat ¶ added in v1.80.0
func (c *Conditions) Concat(more *Conditions) Conditions
Concat concatenates conditions and returns itself.
func (*Conditions) Contains ¶ added in v1.80.0
func (c *Conditions) Contains(condition bool) bool
Contains returns whether the conditions collection contains the value of a condition.
func (*Conditions) ForEach ¶ added in v1.80.0
func (c *Conditions) ForEach(each func(bool) error) error
ForEach will execute function each() on every condition unless an error is returned and will end add this point.
func (*Conditions) Negate ¶ added in v1.80.0
func (c *Conditions) Negate() Conditions
Negate returns a new set of conditions with negated values.
func (*Conditions) OneHot ¶ added in v1.80.0
func (c *Conditions) OneHot() bool
OneHot performs an `OneHot` operation on all conditions
func (*Conditions) Or ¶ added in v1.80.0
func (c *Conditions) Or() bool
Or performs an `Or` operation on all conditions
func (*Conditions) Xor ¶ added in v1.80.0
func (c *Conditions) Xor() bool
Xor performs a `Xor` operation on all conditions
type FilterFunc ¶ added in v1.120.0
func OppositeFunc ¶ added in v1.134.0
func OppositeFunc[E any](f FilterFunc[E]) FilterFunc[E]
OppositeFunc returns the opposite of a FilterFunc.
type MapFunc ¶ added in v1.120.0
type MapFunc[T1, T2 any] func(T1) T2
func IdentityMapFunc ¶ added in v1.120.0
type MapWithErrorFunc ¶ added in v1.124.0
type Predicate ¶ added in v1.134.0
type Predicate[E any] = FilterFunc[E]
type ReduceFunc ¶ added in v1.120.0
type ReduceFunc[T1, T2 any] func(T2, T1) T2
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pagination provides a ways to iterate over collections.
|
Package pagination provides a ways to iterate over collections. |