Documentation
¶
Overview ¶
Package linq provides extra features for go's standard iter library.
Index ¶
- Variables
- func Equal[E comparable](s1, s2 Seq[E]) (bool, error)
- func Max[E cmp.Ordered](s Seq[E]) (E, error)
- func Min[E cmp.Ordered](s Seq[E]) (E, error)
- type Entry
- type Seq
- func ChanValues[V any](c <-chan V) Seq[V]
- func Concat[E any](seqs ...Seq[E]) Seq[E]
- func Elements[E any](es ...E) Seq[E]
- func Empty[E any]() Seq[E]
- func Error[E any](err error) Seq[E]
- func Increment(start, step int) Seq[int]
- func Map[E, R any](s Seq[E], f func(E) (R, error)) Seq[R]
- func MapEntries[K comparable, V any, M ~map[K]V](m M) Seq[Entry[K, V]]
- func MapKeys[K comparable, V any, M ~map[K]V](m M) Seq[K]
- func MapValues[K comparable, V any, M ~map[K]V](m M) Seq[V]
- func Repeat[E any](e E) Seq[E]
- func Runes(s string) Seq[rune]
- func Sort[E cmp.Ordered](s Seq[E]) Seq[E]
- func Zip[X, Y, R any](xs Seq[X], ys Seq[Y], f func(X, Y) (R, error)) Seq[R]
- func (s Seq[E]) All(f func(E) bool) (bool, error)
- func (s Seq[E]) Any(f func(E) bool) (bool, error)
- func (s Seq[E]) Append(es ...E) Seq[E]
- func (s Seq[E]) Collect() ([]E, error)
- func (s Seq[E]) Count() (int, error)
- func (s Seq[E]) Equal(other Seq[E], eq func(E, E) bool) (bool, error)
- func (s Seq[E]) Filter(f func(E) bool) Seq[E]
- func (s Seq[E]) First() (E, error)
- func (s Seq[E]) Force() Seq[E]
- func (s Seq[E]) Get(index int) (E, error)
- func (s Seq[E]) IsEmpty() (bool, error)
- func (s Seq[E]) Last() (E, error)
- func (s Seq[E]) Max(cmp func(E, E) int) (E, error)
- func (s Seq[E]) Min(cmp func(E, E) int) (E, error)
- func (s Seq[E]) Reverse() Seq[E]
- func (s Seq[E]) Single() (E, error)
- func (s Seq[E]) Skip(n int) Seq[E]
- func (s Seq[E]) SkipFunc(f func(E) bool) Seq[E]
- func (s Seq[E]) SkipLast(n int) Seq[E]
- func (s Seq[E]) SkipLastFunc(f func(E) bool) Seq[E]
- func (s Seq[E]) Sort(cmp func(E, E) int) Seq[E]
- func (s Seq[E]) SortStable(cmp func(E, E) int) Seq[E]
- func (s Seq[E]) Take(n int) Seq[E]
- func (s Seq[E]) TakeFunc(f func(E) bool) Seq[E]
- func (s Seq[E]) TakeLast(n int) Seq[E]
- func (s Seq[E]) TakeLastFunc(f func(E) bool) Seq[E]
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("linq: element is not found") ErrNotSingle = errors.New("linq: sequence is not single") )
Errors.
Functions ¶
Types ¶
type Entry ¶ added in v0.2.0
type Entry[K comparable, V any] struct { Key K // The map key. Value V // The map value. }
Entry represents an entry of map.
type Seq ¶
Seq represents a sequence of elements.
func ChanValues ¶ added in v0.2.0
ChanValues returns a sequence that contains the chan values.
func MapEntries ¶ added in v0.2.0
func MapEntries[K comparable, V any, M ~map[K]V](m M) Seq[Entry[K, V]]
MapEntries returns a sequence that contains the map entries.
func MapKeys ¶ added in v0.2.0
func MapKeys[K comparable, V any, M ~map[K]V](m M) Seq[K]
MapKeys returns a sequence that contains the map keys.
func MapValues ¶ added in v0.2.0
func MapValues[K comparable, V any, M ~map[K]V](m M) Seq[V]
MapValues returns a sequence that contains the map values.
func Zip ¶
Zip applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.
func (Seq[E]) Equal ¶
Equal reports whether two sequences are equal using an equality function on each pair of elements.
func (Seq[E]) Single ¶
Single checks that this sequence has only one element and returns that element.
func (Seq[E]) Skip ¶
Skip skips a specified number of elements in a sequence and then returns the remaining elements.
func (Seq[E]) SkipFunc ¶
SkipFunc skips elements in a sequence by f and returns the remaining elements.
func (Seq[E]) SkipLast ¶
SkipLast returns a new sequence that contains the elements from source with the last count elements of the sequence omitted.
func (Seq[E]) SkipLastFunc ¶
SkipLastFunc skips last elements in a sequence by f and returns the remaining elements.
func (Seq[E]) SortStable ¶
SortStable sorts the sequence in ascending order as determined by the cmp function, keeping the original order of equal elements.
func (Seq[E]) Take ¶
Take returns a specified number of contiguous elements from the start of a sequence.
func (Seq[E]) TakeFunc ¶
TakeFunc returns elements from a sequence as long as a specified condition is true.
func (Seq[E]) TakeLastFunc ¶
TakeLastFunc returns last elements from a sequence as long as a specified condition is true.