Documentation
¶
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 InSet[T comparable](set map[T]struct{}, item T) bool
- func InSetAny[T comparable](haystack map[T]struct{}, needles []T) bool
- 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 MakeSet[T comparable](items []T) map[T]struct{}
- 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
- func (c *ConcurrentStringMap[T]) Delete(key string)
- func (c *ConcurrentStringMap[T]) DeleteAll()
- func (c *ConcurrentStringMap[T]) Get(key string) (T, bool)
- func (c *ConcurrentStringMap[T]) Keys() (result []string)
- func (c *ConcurrentStringMap[T]) KeysAndValues() (keys []string, values []T)
- func (c *ConcurrentStringMap[T]) Put(key string, val T)
- func (c *ConcurrentStringMap[T]) Values() (result []T)
- type LookupTable
- 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 InSet ¶ added in v1.2.151
func InSet[T comparable](set map[T]struct{}, item T) bool
Generic InSet function that checks membership in a set
func InSetAny ¶ added in v1.2.151
func InSetAny[T comparable](haystack map[T]struct{}, needles []T) bool
InSetAny returns true if any item in 'needles' is found in 'haystack'
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 MakeSet ¶ added in v1.2.151
func MakeSet[T comparable](items []T) map[T]struct{}
Generic MakeSet function that builds a set from a slice
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 ¶
ConcurrentStringMap enable safe shared map with Read/Write locks
func NewConcurrentStringMap ¶
func NewConcurrentStringMap[T any]() ConcurrentStringMap[T]
NewConcurrentStringMap factory method
func (*ConcurrentStringMap[T]) Delete ¶ added in v1.2.98
func (c *ConcurrentStringMap[T]) Delete(key string)
Delete remove item from map
func (*ConcurrentStringMap[T]) DeleteAll ¶ added in v1.2.98
func (c *ConcurrentStringMap[T]) DeleteAll()
DeleteAll remove all items from the map
func (*ConcurrentStringMap[T]) Get ¶
func (c *ConcurrentStringMap[T]) Get(key string) (T, bool)
Get retrieve item from map
func (*ConcurrentStringMap[T]) Keys ¶ added in v1.2.63
func (c *ConcurrentStringMap[T]) Keys() (result []string)
Keys returns all the keys in the map
func (*ConcurrentStringMap[T]) KeysAndValues ¶ added in v1.2.63
func (c *ConcurrentStringMap[T]) KeysAndValues() (keys []string, values []T)
KeysAndValues returns all the keys and the values in the map
func (*ConcurrentStringMap[T]) Put ¶
func (c *ConcurrentStringMap[T]) Put(key string, val T)
Put set item in the map
func (*ConcurrentStringMap[T]) Values ¶ added in v1.2.63
func (c *ConcurrentStringMap[T]) Values() (result []T)
Values returns all the values in the map
type LookupTable ¶ added in v1.2.161
LookupTable is a generic lookup table with string keys and values of type T
func (LookupTable[T]) Clear ¶ added in v1.2.163
func (lt LookupTable[T]) Clear()
Clear removes all entries from the table.
func (LookupTable[T]) Contains ¶ added in v1.2.163
func (lt LookupTable[T]) Contains(key string) bool
Contains returns true if the given key exists in the table.
func (LookupTable[T]) Delete ¶ added in v1.2.162
func (lt LookupTable[T]) Delete(key string)
Delete removes the entry for the given key, if it exists.
func (LookupTable[T]) Get ¶ added in v1.2.161
func (lt LookupTable[T]) Get(key string) (T, bool)
Get returns the value and a bool indicating if it was found
func (LookupTable[T]) Keys ¶ added in v1.2.161
func (lt LookupTable[T]) Keys() []string
Keys returns all keys in the table
func (LookupTable[T]) Len ¶ added in v1.2.162
func (lt LookupTable[T]) Len() int
Len returns the number of elements in the table.
func (LookupTable[T]) Values ¶ added in v1.2.161
func (lt LookupTable[T]) Values() []T
Values returns all values in the table
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