sak

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

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(fn func(elem interface{}) bool, iterable interface{}) bool

All returns true if all elements in iter satisfy fn.

func Any

func Any(fn func(elem interface{}) bool, iterable interface{}) bool

Any returns true if any element in iter satisfies fn.

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 IntIn

func IntIn(i int, is []int) bool

func IntOr

func IntOr(i int, is ...int) int

func IsZero

func IsZero(i interface{}) bool

func JSONMustMarshal

func JSONMustMarshal(v interface{}) []byte

func JSONMustUnmarshal

func JSONMustUnmarshal(data []byte, v interface{})

func StrIn

func StrIn(s string, ss []string) bool

func StrOr

func StrOr(s string, ss ...string) string

func UintIn

func UintIn(i uint, is []uint) bool

func UintOr

func UintOr(i uint, is ...uint) uint

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.

Jump to

Keyboard shortcuts

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