Documentation ¶
Overview ¶
Copyright 2022. Motty Cohen.
We often need our programs to perform operations on collections of data, like selecting all items that satisfy a given predicate or mapping all items to a new collection with a custom function.
Copyright 2022. Motty Cohen.
Index ¶
- func AddIfNotExists(vs []string, t string) []string
- func All(vs []string, f func(string) bool) bool
- func AllN(vs []int, f func(int) bool) bool
- func Any(vs []string, f func(string) bool) bool
- func AnyN(vs []int, f func(int) bool) bool
- func BitMaskInclude(src, flag int) bool
- func Concat(slices ...[]string) []string
- func ConcatN(slices ...[]int) []int
- func Distinct(vs []string) []string
- func DistinctN(vs []int) []int
- func Filter(vs []string, f func(string) bool) []string
- func FilterN(vs []int, f func(int) bool) []int
- func Include(vs []string, t string) bool
- func IncludeMask(vs []int, t int) bool
- func IncludeN(vs []int, t int) bool
- func Index(vs []string, t string) int
- func IndexN(vs []int, t int) int
- func Intersect(slices ...[]string) []string
- func IntersectN(slices ...[]int) []int
- func JoinN(slice []int, sep string) string
- func Map(vs []string, f func(string) string) []string
- func MapN(vs []int, f func(int) int) []int
- func Remove(vs []string, t string) []string
- type ConcurrentStringMap
- type Queue
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddIfNotExists ¶
Add item to list only if it does not exist
func BitMaskInclude ¶
BitMaskInclude checks if the src bitmask including the flag
func Filter ¶
Filter returns a new slice containing all strings in the slice that satisfy the predicate `f`.
func FilterN ¶
FilterN returns a new slice containing all integers in the slice that satisfy the predicate `f`.
func IncludeMask ¶
func IntersectN ¶
Intersect returns only the values in all slices
func JoinN ¶
JoinN convert all integers in the slice to strings and joins them together as a single string with separator
func Map ¶
Map returns a new slice containing the results of applying the function `f` to each string in the original slice.
Types ¶
type ConcurrentStringMap ¶
func NewConcurrentStringMap ¶
func NewConcurrentStringMap() ConcurrentStringMap
func (*ConcurrentStringMap) Get ¶
func (c *ConcurrentStringMap) Get(key string) (val string)
func (*ConcurrentStringMap) Put ¶
func (c *ConcurrentStringMap) Put(key string, val string)
type Queue ¶
type Queue interface { // Push item into a queue Push(v any) // Pop last item Pop() (any, bool) // Length get length of the queue Length() int }
Queue functions for manager data items in a stack
type Stack ¶
type Stack interface { // push item into a stack Push(v any) // pop last item Pop() (any, bool) // pop many items PopMany(count int64) ([]any, bool) // pop all items PopAll() ([]any, bool) // peek last item Peek() (any, bool) // get length of stack Length() int64 // is empty stack IsEmpty() bool }
Stack functions for manager data items in a stack