Documentation
¶
Index ¶
- func Filter[CollectionItem any](items []CollectionItem, filterFunc func(item CollectionItem, index int) bool) []CollectionItem
- func Find[CollectionItem any](items []CollectionItem, findFunc func(item CollectionItem, index int) bool) CollectionItem
- func FindIndex[CollectionItem any](items []CollectionItem, findFunc func(item CollectionItem, index int) bool) int
- func Map[Input any, Output any](inputs []Input, mapFunc func(input Input, index int) Output) []Output
- func MapToSlice[Value any](inputMap map[string]Value) []Value
- func RemoveDuplicates[Value comparable](input []Value) []Value
- func Reverse[Value any](items []Value) []Value
- func ShallowCopyMap[Key comparable, Value any](inputMap map[Key]Value) map[Key]Value
- func SliceContains[Value Comparable[Value]](input []Value, searchFor Value) bool
- func SliceContainsComparable[Value comparable](input []Value, searchFor Value) bool
- func SliceToMapKeys[Value any](inputKeys []string) map[string][]Value
- func SlicesEqual[Value comparable](a []Value, b []Value) bool
- type Clock
- type Comparable
- type SystemClock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter[CollectionItem any](items []CollectionItem, filterFunc func(item CollectionItem, index int) bool) []CollectionItem
Filter deals with filtering a slice of items down to all those items that meet the predicate of the filter function.
func Find ¶
func Find[CollectionItem any](items []CollectionItem, findFunc func(item CollectionItem, index int) bool) CollectionItem
Find deals with finding the first occurence of an item in a given slice of items. For complex data types CollectionItem should be a pointer.
func FindIndex ¶
func FindIndex[CollectionItem any](items []CollectionItem, findFunc func(item CollectionItem, index int) bool) int
FindIndex deals with finding the index of the first occurence of an item in a given slice of items. Returns -1 when item can not be found.
func Map ¶
func Map[Input any, Output any](inputs []Input, mapFunc func(input Input, index int) Output) []Output
Map deals with mapping a slice of Inputs to a slice of Outputs with the given mapping function.
func MapToSlice ¶
MapToSlice converts a map to a slice of values. Order is not guaranteed so do not use this where the order of items in the slice matters.
func RemoveDuplicates ¶
func RemoveDuplicates[Value comparable](input []Value) []Value
RemoveDuplicates deals with removing duplicating values in the given slice. This only supports value types that fulfil the built-in comparable interface.
func Reverse ¶
func Reverse[Value any](items []Value) []Value
Reverse deals with producing a copy of a given slice with items in the reverse order. This does not mutate the input slice!
func ShallowCopyMap ¶
func ShallowCopyMap[Key comparable, Value any](inputMap map[Key]Value) map[Key]Value
ShallowCopyMap deals with making a copy of a map, shallow copying the values into the new map.
func SliceContains ¶
func SliceContains[Value Comparable[Value]](input []Value, searchFor Value) bool
SliceContains determines whether the provided slice contains the given searchFor value.
func SliceContainsComparable ¶
func SliceContainsComparable[Value comparable](input []Value, searchFor Value) bool
SliceContainsComparable determines whether the provided slice contains the given searchFor value where the value fulfils the built-in comparable interface, complex structs will not fulfil this interface and therefore you should implement the Equal() interface and use SliceContains.
func SliceToMapKeys ¶
SliceToMapKeys converts a slice of strings to a map where each item in the slice is a key in the map for an empty slice of values. This only works where the values in a map are slices!
func SlicesEqual ¶
func SlicesEqual[Value comparable](a []Value, b []Value) bool
SlicesEqual determines whether to slices of the same comparable type are equal in value.
Types ¶
type Comparable ¶
Comparable provides a custom interface for more complex equality checks between two values of the same type.
type SystemClock ¶
type SystemClock struct{}
SystemClock is a Clock that returns the current time derived from the host system.
func (SystemClock) Now ¶
func (d SystemClock) Now() time.Time