Documentation
¶
Index ¶
- func Filter[T any](s []T, f func(T) bool) []T
- func Map[T any, U any](s []T, f func(T) U) []U
- func OrPanic2[T any](value T, err error) func(message string) T
- func ReadLines(filep string) (lines []string, err error)
- func Tri[T any](condition bool, a, b T) T
- type Pair
- type Set
- func (v *Set[T]) Add(item T) (added bool)
- func (v *Set[T]) Clear()
- func (v *Set[T]) Contains(item T) bool
- func (v *Set[T]) Count() int
- func (v *Set[T]) Equal(s *Set[T]) bool
- func (v *Set[T]) ForEach(f func(each T, stop func()))
- func (v *Set[T]) Has(item T) bool
- func (v *Set[T]) Len() int
- func (v *Set[T]) Remove(item T) (existed bool)
- func (v *Set[T]) ToSlice() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter values in s with f. When f returns true, item is included in the response slice.
func OrPanic2 ¶
OrPanic2 return function that returns value if err is nil, else panics with message.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a naive map backed set.
func (*Set[T]) Add ¶
Add item to the set, return true if it was added. Otherwise it already existed.
func (*Set[T]) ForEach ¶
func (v *Set[T]) ForEach(f func(each T, stop func()))
ForEach iterates all items in the set, calls f for each item, stops if stop is called.
Click to show internal directories.
Click to hide internal directories.