Documentation ¶
Index ¶
- func AddInt(a, b int) int
- func AddNum[T Number](a, b T) T
- func AllMatch[T any](datas []T, f func(T) bool) bool
- func AnyMatch[T any](datas []T, f func(T) bool) bool
- func Filter[T any](datas []T, f func(T) bool) []T
- func ForEach[T any](datas []T, f func(T))
- func Map[T any](datas []T, f func(T) T) []T
- func Reduce[T any](datas []T, result []T, f func(T, []T) []T) []T
- func SliceMax[T cmp.Ordered](s []T) T
- func SumFloats(m map[string]float64) float64
- func SumInts(m map[string]int64) int64
- func SumNumber[K comparable, V Number](m map[string]V) V
- type GenericQueue
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶
func Map[T any](datas []T, f func(T) T) []T
Map processes and group elements by function f
func Reduce ¶
func Reduce[T any](datas []T, result []T, f func(T, []T) []T) []T
Reduce process elements by func f and return
func SumNumber ¶
func SumNumber[K comparable, V Number](m map[string]V) V
SumNumber returns the sum of map values
Types ¶
type GenericQueue ¶
type GenericQueue[T any] struct { // contains filtered or unexported fields }
GenericQueue queue implemented by the generic
func NewGenericQueue ¶
func NewGenericQueue[T any](capacity int) *GenericQueue[T]
NewGenericQueue creates a new GenericQueue instance
func (*GenericQueue[T]) Peek ¶
func (q *GenericQueue[T]) Peek() (_ T)
Peek get the front element of the GenericQueue
func (*GenericQueue[T]) Pop ¶
func (q *GenericQueue[T]) Pop() (_ T)
Pop remove front element of the GenericQueue
func (*GenericQueue[T]) Push ¶
func (q *GenericQueue[T]) Push(v T)
Push insert element into the GenericQueue
func (*GenericQueue[T]) Size ¶
func (q *GenericQueue[T]) Size() int
Size returns the size of the GenericQueue
Click to show internal directories.
Click to hide internal directories.