cow

package module
v0.0.0-...-a00fdcb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

CoW (Collection Wrappers)

Golang generic collections

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupBy

func GroupBy[T any, K comparable](in Slice[T], groupOf func(x T) K) map[K]Slice[T]

func Reduce

func Reduce[TIN any, TOUT any](in Slice[TIN], init TOUT, f func(init TOUT, new TIN) TOUT) TOUT

Types

type Set

type Set[K comparable] map[K]bool

func NewSet

func NewSet[K comparable](in ...K) Set[K]

func (Set[T]) All

func (x Set[T]) All(f func(T) bool) bool

func (Set[T]) Any

func (x Set[T]) Any(f func(T) bool) bool

func (Set[K]) Contains

func (s Set[K]) Contains(k K) bool

func (Set[T]) CountWhere

func (x Set[T]) CountWhere(f func(T) bool) (out int)

func (Set[T]) Filter

func (x Set[T]) Filter(f func(T) bool) Set[T]

func (Set[K]) Insert

func (s Set[K]) Insert(k K) bool

func (Set[K]) Intersect

func (s Set[K]) Intersect(other Set[K]) Set[K]

func (Set[K]) String

func (x Set[K]) String() string

func (Set[K]) ToSlice

func (s Set[K]) ToSlice() (out Slice[K])

func (Set[K]) Union

func (s Set[K]) Union(other Set[K]) Set[K]

type Slice

type Slice[T any] []T

func Map

func Map[T any, K any](in Slice[T], f func(T) K) Slice[K]

func NewSlice

func NewSlice[T any](in ...T) Slice[T]

func (Slice[T]) All

func (x Slice[T]) All(f func(T) bool) bool

func (Slice[T]) Any

func (x Slice[T]) Any(f func(T) bool) bool

func (Slice[T]) CountWhere

func (x Slice[T]) CountWhere(f func(T) bool) (out int)

func (Slice[T]) Filter

func (x Slice[T]) Filter(f func(T) bool) (res Slice[T])

func (Slice[T]) Reduce

func (x Slice[T]) Reduce(init T, f func(init T, new T) T) T

func (Slice[T]) SortFunc

func (x Slice[T]) SortFunc(cmp func(x, y T) int) Slice[T]

func (Slice[T]) UniqueFunc

func (x Slice[T]) UniqueFunc(cmp func(x, y T) bool) Slice[T]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL