Documentation
¶
Index ¶
- func All[T comparable](val T, arr []T) bool
- func Allf[T any](foo func(v T) bool, arr []T) bool
- func Any[T comparable](val T, arr []T) bool
- func Anyf[T any](foo func(v T) bool, arr []T) bool
- func Drop[T any, U constraints.Unsigned](num U, arr []T) []T
- func DropRunes[T constraints.Unsigned](num T, what string) string
- func DropString[T constraints.Unsigned](num T, what string) string
- func Equals[T comparable](a, b T) bool
- func EqualsClosure[T comparable](a T) func(T) bool
- func Filter[T any](f func(T) bool, arr []T) []T
- func First[T any](x []T) T
- func GenericWorker[A, B any](inputs <-chan A, outputs chan<- B, work func(A) B, wg *sync.WaitGroup)
- func GenericWorkers[A, B any](inputs <-chan A, work func(A) B, workers int, cz int) <-chan B
- func GetPointer[T any](val T) *T
- func Greater[T constraints.Ordered](a, b T) bool
- func Last[T any](x []T) T
- func Less[T constraints.Ordered](a, b T) bool
- func Map[T, S any](f func(T) S, arr []T) []S
- func Max[T constraints.Ordered](a, b T) T
- func Maxf[T any](less func(T, T) bool, vals ...T) T
- func Maxv[T constraints.Ordered](vals ...T) T
- func Min[T constraints.Ordered](a, b T) T
- func MinMaxf[T any](less func(T, T) bool, vals ...T) (T, T)
- func MinMaxv[T constraints.Ordered](vals ...T) (T, T)
- func Minf[T any](less func(T, T) bool, vals ...T) T
- func Minv[T constraints.Ordered](vals ...T) T
- func PeekString[T constraints.Unsigned](num T, what string) string
- func RemoveIf[T any](f func(T) bool, arr []T) []T
- func Repeat[T any](val T, size int) []T
- func Skip[T any, U constraints.Unsigned](num U, arr []T) []T
- func SkipRunes[T constraints.Unsigned](num T, what string) string
- func SkipString[T constraints.Unsigned](num T, what string) string
- func Tail[T any](num int, arr []T) []T
- func Take[T any](num int, arr []T) []T
- func TakeString[T constraints.Unsigned](num T, what string) string
- func ZeroValue[T any]() T
- type Set
- func (s *Set[T]) Add(v T)
- func (s *Set[T]) Clear()
- func (s *Set[T]) Contains(v T) bool
- func (s *Set[T]) Difference(other *Set[T]) *Set[T]
- func (s *Set[T]) Intersection(other *Set[T]) *Set[T]
- func (s *Set[T]) IsDisjoint(other *Set[T]) bool
- func (s *Set[T]) IsEqual(other *Set[T]) bool
- func (s *Set[T]) IsSubset(other *Set[T]) bool
- func (s *Set[T]) IsSuperset(other *Set[T]) bool
- func (s *Set[_]) Len() int
- func (s *Set[T]) Remove(v T)
- func (s *Set[T]) SymmetricDifference(other *Set[T]) *Set[T]
- func (s *Set[T]) Union(other *Set[T]) *Set[T]
- func (s *Set[T]) Values() []T
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
func All[T comparable](val T, arr []T) bool
All returns true if all elements in the list match the given value.
func Any ¶
func Any[T comparable](val T, arr []T) bool
Any returns true if any element in the list matches the given value.
func Drop ¶
func Drop[T any, U constraints.Unsigned](num U, arr []T) []T
Drop allocates a new slice, with the first `num` elements dropped.
func DropRunes ¶
func DropRunes[T constraints.Unsigned](num T, what string) string
DropRunes allocates a new string, with the first `num` runes of a string dropped.
func DropString ¶
func DropString[T constraints.Unsigned](num T, what string) string
DropString allocates a new string, with the first `num` bytes of a string dropped.
func Equals ¶
func Equals[T comparable](a, b T) bool
Equals is the default equals function for any ordered type and will return true if a = b, false otherwise.
func EqualsClosure ¶
func EqualsClosure[T comparable](a T) func(T) bool
Equals is the default equals function that will return a closure equals function to compare the value to the original wrapped val.
func First ¶
func First[T any](x []T) T
First returns the first element of the given array, zero value otherwise.
func GenericWorker ¶
func GenericWorker[A, B any]( inputs <-chan A, outputs chan<- B, work func(A) B, wg *sync.WaitGroup, )
GenericWorker gets values from `inputs channel`, performs `work` on the value and puts it into the `outputs` channel, while also marking itself as `Done` in `WaitGroup` when `inputs` channel is closed.
func GenericWorkers ¶
GenericWorkers spins up given number of `genericWorker` routines that all perform `work` and it itself returns the `outputs` channel with the buffer defined by `cz`; do close the `inputs` channel when there is no more work left for workers to safely exit their goroutines.
func Greater ¶
func Greater[T constraints.Ordered](a, b T) bool
DefaultLess is the default greater function for any ordered type and will return true if a > b, false otherwise.
func Last ¶
func Last[T any](x []T) T
Last returns the last element of the given array, zero value otherwise.
func Less ¶
func Less[T constraints.Ordered](a, b T) bool
Less is the default less function for any ordered type and will return true if a < b, false otherwise.
func Map ¶
func Map[T, S any](f func(T) S, arr []T) []S
Map calls the function on every array element and returns results in list.
func Maxf ¶
Maxf returns the maximum of the given values with a given "less" comparator, or if no values are given, the zero value of the type.
func Maxv ¶
func Maxv[T constraints.Ordered](vals ...T) T
Maxv returns the maximum of the given values, or if no values are given, the zero value of the type.
func MinMaxf ¶
MinMaxv returns the minimum and maximum of the given values with a given "less" comparator, or if no values are given, two zero value of the type.
func MinMaxv ¶
func MinMaxv[T constraints.Ordered](vals ...T) (T, T)
MinMaxv returns the minimum and maximum of the given values, or if no values are given, two zero value of the type.
func Minf ¶
Minf returns the minimum of the given values with a given "less" comparator, or if no values are given, the zero value of the type.
func Minv ¶
func Minv[T constraints.Ordered](vals ...T) T
Minv returns the minimum of the given values, or if no values are given, the zero value of the type.
func PeekString ¶
func PeekString[T constraints.Unsigned](num T, what string) string
PeekString takes the first `num` bytes of a string by slicing (underlying array unaffected).
func Skip ¶
func Skip[T any, U constraints.Unsigned](num U, arr []T) []T
Skips skips the first `num` elements by slicing (underlying array unaffected).
func SkipRunes ¶
func SkipRunes[T constraints.Unsigned](num T, what string) string
SkipRunes skips the first `num` runes of a string by slicing (underlying array unaffected).
func SkipString ¶
func SkipString[T constraints.Unsigned](num T, what string) string
SkipString skips the first `num` bytes of a string by slicing (underlying array unaffected).
func TakeString ¶
func TakeString[T constraints.Unsigned](num T, what string) string
TakeString allocates a new string, with the first `num` bytes of a string taken.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func (*Set[T]) Difference ¶
Difference returns a new set with elements that are in s but not in other.
func (*Set[T]) Intersection ¶
Intersection returns a new set with elements that are both in s and other.
func (*Set[T]) IsDisjoint ¶
IsDisjoint returns true if s and other have no elements in common.
func (*Set[T]) IsSuperset ¶
IsSuperset returns true if s is a superset of other.
func (*Set[T]) SymmetricDifference ¶
SymmetricDifference returns a new set with elements that are in either s or other but not both.
type Tuple ¶
type Tuple[A, B any] struct { First A Second B }
Tuple is a generic tuple type.
func Zip ¶
Zip returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument lists.