Documentation
¶
Index ¶
- func All(fn func(elem interface{}) bool, iterable interface{}) bool
- func Any(fn func(elem interface{}) bool, iterable interface{}) bool
- func Filter(fn func(elem interface{}) bool, iterable interface{}) []interface{}
- func First(fn func(elem interface{}) bool, iterable interface{}) interface{}
- func In(elem interface{}, iterable interface{}) bool
- func Index(elem interface{}, iterable interface{}) int
- func IntIn(i int, is []int) bool
- func IntOr(i int, is ...int) int
- func IsZero(i interface{}) bool
- func JSONMustMarshal(v interface{}) []byte
- func JSONMustUnmarshal(data []byte, v interface{})
- func StrIn(s string, ss []string) bool
- func StrOr(s string, ss ...string) string
- func UintIn(i uint, is []uint) bool
- func UintOr(i uint, is ...uint) uint
- type Iterable
- type Iterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter(fn func(elem interface{}) bool, iterable interface{}) []interface{}
Filter creates a slice of elements that satisfy fn.
func First ¶
func First(fn func(elem interface{}) bool, iterable interface{}) interface{}
First returns the first element from iter that satisfies fn. Returns nil if no element satisfies fn.
func In ¶
func In(elem interface{}, iterable interface{}) bool
In returns true if elem is found in iterable. elem and elements in iterable must be comparable.
func Index ¶
func Index(elem interface{}, iterable interface{}) int
Index returns the index of elem into the data structure behind iterable. This only makes sense if the backing data structure is ordered and indexable. Returns -1 if elem is not found in iterable. elem and elements in iterable must be comparable.
func JSONMustMarshal ¶
func JSONMustMarshal(v interface{}) []byte
func JSONMustUnmarshal ¶
func JSONMustUnmarshal(data []byte, v interface{})
Types ¶
type Iterable ¶
type Iterable interface {
// Iter returns an Iterator for the backing data structure.
Iter() Iterator
}
type Iterator ¶
type Iterator interface {
// HasNext returns true if there is more data in this Iterator.
HasNext() bool
// Next returns the next datum in this Iterator.
// Next will panic
Next() interface{}
}
func Iter ¶
func Iter(iterable interface{}) Iterator
Iter returns an Iterator around an iterable, specifically:
an array, a slice, an Iterable, or another Iterator.
Calling Iter on an Iterator is idempotent and just returns the Iterator. If iterable is a slice or array, concurrent modifications to the iterable could cause unexpected results.