Documentation
¶
Index ¶
- func All[T any](iter iter.Seq[T], predicate Predicate[T]) bool
- func All2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) bool
- func Any[T any](iter iter.Seq[T], predicate Predicate[T]) bool
- func Any2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) bool
- func Append[T any](iter iter.Seq[T], v T) iter.Seq[T]
- func Append2[K comparable, V any](iter iter.Seq2[K, V], k K, v V) iter.Seq2[K, V]
- func Concat[T any](iters ...iter.Seq[T]) iter.Seq[T]
- func Concat2[K comparable, V any](iters ...iter.Seq2[K, V]) iter.Seq2[K, V]
- func Contains[T comparable](iter iter.Seq[T], item T) bool
- func Count[T any](iter iter.Seq[T], predicate Predicate[T]) int
- func Count2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) int
- func Equal[T comparable](iter1, iter2 iter.Seq[T]) bool
- func Equal2[K comparable, V comparable](iter1, iter2 iter.Seq2[K, V]) bool
- func Filter[T any](iter iter.Seq[T], predicate Predicate[T]) iter.Seq[T]
- func Filter2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) iter.Seq2[K, V]
- func Find[T any](iter iter.Seq[T], predicate Predicate[T]) (T, bool)
- func Find2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) (K, V, bool)
- func First[T any](iter iter.Seq[T]) T
- func First2[K comparable, V any](iter iter.Seq2[K, V]) (K, V)
- func ForEach[T any](iter iter.Seq[T], f func(T))
- func ForEach2[K comparable, V any](iter iter.Seq2[K, V], f func(K, V))
- func IsEmpty[T any](iter iter.Seq[T]) bool
- func IsEmpty2[K comparable, V any](iter iter.Seq2[K, V]) bool
- func IsValidKey[K comparable, V any](iter iter.Seq2[K, V], key K) bool
- func Keys[K comparable, V any](iter iter.Seq2[K, V]) iter.Seq[K]
- func Last[T any](iter iter.Seq[T]) T
- func Last2[K comparable, V any](iter iter.Seq2[K, V]) (K, V)
- func Len[T any](iter iter.Seq[T]) int
- func Len2[K comparable, V any](iter iter.Seq2[K, V]) int
- func Map[T, U any](iter iter.Seq[T], f func(T) U) iter.Seq[U]
- func Map12[K comparable, V, U any](iter iter.Seq[V], f func(V) (K, U)) iter.Seq2[K, U]
- func Map2[K, L comparable, V, U any](iter iter.Seq2[K, V], f func(K, V) (L, U)) iter.Seq2[L, U]
- func Map21[K comparable, V, U any](iter iter.Seq2[K, V], f func(K, V) U) iter.Seq[U]
- func Max[T cmp.Ordered](iter iter.Seq[T]) T
- func Max2[K comparable, V cmp.Ordered](iter iter.Seq2[K, V]) (K, V)
- func Middle[T any](iter iter.Seq[T]) T
- func Middle2[K comparable, V any](iter iter.Seq2[K, V]) (K, V)
- func Min[T cmp.Ordered](iter iter.Seq[T]) T
- func Min2[K comparable, V cmp.Ordered](iter iter.Seq2[K, V]) (K, V)
- func NewFromFunc[T any](f func() T, n int) iter.Seq[T]
- func NewFromFunc2[K comparable, V any](f func() (K, V), n int) iter.Seq2[K, V]
- func NewFromFuncIterations[T any](f func(int) T, n int) iter.Seq[T]
- func NewFromFuncIterations2[K comparable, V any](f func(int) (K, V), n int) iter.Seq2[K, V]
- func NewFromMap[K comparable, V any](m map[K]V) iter.Seq2[K, V]
- func NewFromRepeat[T any](value T, count int) iter.Seq[T]
- func NewFromSlice[T any](slice []T) iter.Seq[T]
- func NewFromSlice2[T any](slice []T) iter.Seq2[int, T]
- func None[T any](iter iter.Seq[T], predicate Predicate[T]) bool
- func None2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) bool
- func Product[T types.Number](iter iter.Seq[T]) T
- func Product2[K comparable, V types.Number](iter iter.Seq2[K, V]) V
- func Reduce[T any](iter iter.Seq[T], f func(T, T) T, initialValue T) T
- func Reduce2[K comparable, V any](iter iter.Seq2[K, V], f func(V, V, K) V, initialValue V) V
- func RemoveKey[K comparable, V any](iter iter.Seq2[K, V], key K) iter.Seq2[K, V]
- func RemoveNth[T any](iter iter.Seq[T], index int) iter.Seq[T]
- func Skip[T any](iter iter.Seq[T], n int) iter.Seq[T]
- func Skip2[K comparable, V any](iter iter.Seq2[K, V], n int) iter.Seq2[K, V]
- func Sort[T cmp.Ordered](iter iter.Seq[T], less func(T, T) bool) iter.Seq[T]
- func Sort2[K comparable, V cmp.Ordered](iter iter.Seq2[K, V], less func(K, V, K, V) bool) iter.Seq2[K, V]
- func Split[T any](i iter.Seq[T], predicate func(T) bool) iter.Seq[iter.Seq[T]]
- func Split2[K comparable, V any](i iter.Seq2[K, V], predicate func(K, V) bool) iter.Seq[iter.Seq2[K, V]]
- func Sum[T types.Summable](iter iter.Seq[T]) T
- func Sum2[K comparable, V types.Summable](iter iter.Seq2[K, V]) V
- func Swap[T any](iter iter.Seq[T], i, j int) iter.Seq[T]
- func Swap2[K comparable, V any](iter iter.Seq2[K, V], i, j int) iter.Seq2[K, V]
- func SwapByKey[K comparable, V any](iter iter.Seq2[K, V], key1, key2 K) iter.Seq2[K, V]
- func ToMap[K comparable, V any](iter iter.Seq2[K, V]) map[K]V
- func ToMapN[K comparable, V any](iter iter.Seq2[K, V], n uint) map[K]V
- func ToSlice[T any](iter iter.Seq[T]) []T
- func ToSlice2[K types.Integer, V any](iter iter.Seq2[K, V]) []V
- func ToSliceN[T any](iter iter.Seq[T], n uint) []T
- func Values[K comparable, V any](iter iter.Seq2[K, V]) iter.Seq[V]
- func Zip[T, U, V any](iter1 iter.Seq[T], iter2 iter.Seq[U], f func(T, U) V) iter.Seq[V]
- type Predicate
- type Predicate2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All returns true if all elements in the iter satisfy the predicate and false otherwise. It returns false at the first element that does not satisfy the predicate, and does not check the rest of the elements. If the iter is empty, it returns true. If the iter is nil, it panics.
func All2 ¶
func All2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) bool
All2 returns true if all key-value pairs in the iter satisfy the predicate and false otherwise. It returns false at the first element that does not satisfy the predicate, and does not check the rest of the elements. If the iter is empty, it returns true. If the iter is nil, it panics.
func Any ¶
Any returns true if at least one element in the iter satisfies the predicate and false otherwise. It returns true at the first element that satisfies the predicate, and does not check the rest of the elements. If the iter is empty, it returns false. If the iter is nil, it panics.
func Any2 ¶
func Any2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) bool
Any2 returns true if at least one key-value pair in the iter satisfies the predicate and false otherwise. It returns true at the first element that satisfies the predicate, and does not check the rest of the elements. If the iter is empty, it returns false. If the iter is nil, it panics.
func Append ¶
Append appends the element to the input iterator. If the input iterator is nil, it panics.
func Append2 ¶
Append2 appends the key-value pair to the input iterator. If the input iterator is nil, it panics.
func Concat ¶
Concat concatenates the input iterators and returns a new iterator with the elements of the input iterators. If the input iterators are nil, it panics.
func Concat2 ¶
Concat2 concatenates the input iterators and returns a new iterator with the key-value pairs of the input iterators. If the input iterators are nil, it panics.
func Contains ¶
func Contains[T comparable](iter iter.Seq[T], item T) bool
Contains returns true if the item is in the iter and false otherwise. If the iter is nil, it panics.
func Count ¶
Count returns the number of elements in the iter that satisfy the predicate. If the iter is nil, it panics.
func Count2 ¶
func Count2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) int
Count2 returns the number of key-value pairs in the iter that satisfy the predicate. If the iter is nil, it panics.
func Equal ¶
func Equal[T comparable](iter1, iter2 iter.Seq[T]) bool
Equal returns true if the values in the two iters are equal and false otherwise. If either one of the iters is nil, it panics.
func Equal2 ¶
func Equal2[K comparable, V comparable](iter1, iter2 iter.Seq2[K, V]) bool
Equal2 returns true if the key-value pairs in the two iters are equal and false otherwise. If either one of the iters is nil, it panics.
func Filter ¶
Filter returns a new iterator with the elements that satisfy the predicate. If the input iterator is nil, it panics.
func Filter2 ¶
Filter2 returns a new iterator with the key-value pairs that satisfy the predicate. If the input iterator is nil, it panics.
func Find ¶
Find returns the first element that satisfies the predicate and a boolean. that indicates if such an element was found. If the iter is nil, it panics.
func Find2 ¶
func Find2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) (K, V, bool)
Find2 returns the first key-value pair that satisfies the predicate and a boolean. that indicates if such a pair was found. If the iter is nil, it panics.
func First2 ¶
func First2[K comparable, V any](iter iter.Seq2[K, V]) (K, V)
First2 returns the first key-value pair in the iter. If the iter is empty or nil, it panics.
func ForEach ¶
ForEach applies the function to each element in the iter. If the iter is nil, it panics.
func ForEach2 ¶
func ForEach2[K comparable, V any](iter iter.Seq2[K, V], f func(K, V))
ForEach2 applies the function to each key-value pair in the iter. If the iter is nil, it panics.
func IsEmpty ¶
IsEmpty returns true if the iter is empty and false otherwise. If the iter is nil, it panics.
func IsEmpty2 ¶
func IsEmpty2[K comparable, V any](iter iter.Seq2[K, V]) bool
IsEmpty2 returns true if the iter is empty and false otherwise. If the iter is nil, it panics.
func IsValidKey ¶
func IsValidKey[K comparable, V any](iter iter.Seq2[K, V], key K) bool
IsValidKey returns true if the key is in the iter and false otherwise. If the iter is nil, it panics.
func Keys ¶
Keys returns a new iterator with the keys of the input iterator. If the input iterator is nil, it panics.
func Last2 ¶
func Last2[K comparable, V any](iter iter.Seq2[K, V]) (K, V)
Last2 returns the last key-value pair in the iter. If the iter is empty or nil, it panics.
func Len2 ¶
func Len2[K comparable, V any](iter iter.Seq2[K, V]) int
Len2 returns the number of key-value pairs in the iter. If the iter is nil, it panics.
func Map ¶
Map applies the function to each element of the input iterator and returns a new iterator with the results. If the input iterator is nil, it panics.
func Map12 ¶
Map12 applies the function to each element of the input iterator and returns a new iterator with the resulting key-value pairs. If the input iterator is nil, it panics.
func Map2 ¶
Map2 applies the function to each key-value pair of the input iterator and returns a new iterator with the results. If the input iterator is nil, it panics.
func Map21 ¶
Map21 applies the function to each key-value pair of the input iterator and returns a new iterator with the resulting values. If the input iterator is nil, it panics.
func Max2 ¶
func Max2[K comparable, V cmp.Ordered](iter iter.Seq2[K, V]) (K, V)
Max2 returns the maximum key-value pair in the iter. If the iter is empty or nil, it panics.
func Middle ¶
Middle returns the middle element of the iter. If the iter has an even number of elements, it returns the first element of the second half. If the iter is empty or nil, it panics.
func Middle2 ¶
func Middle2[K comparable, V any](iter iter.Seq2[K, V]) (K, V)
Middle2 returns the middle key-value pair of the iter. If the iter has an even number of elements, it returns the first key-value pair of the second half. If the iter is empty or nil, it panics.
func Min2 ¶
func Min2[K comparable, V cmp.Ordered](iter iter.Seq2[K, V]) (K, V)
Min2 returns the minimum key-value pair in the iter. If the iter is empty or nil, it panics.
func NewFromFunc ¶
NewFromFunc returns a new iterator that yields the values returned by the given function. The function takes no arguments. The length of the iterator is n
func NewFromFunc2 ¶
func NewFromFunc2[K comparable, V any](f func() (K, V), n int) iter.Seq2[K, V]
NewFromFunc2 returns a new iterator that yields the key-value pairs returned by the given function. The function takes no arguments. The length of the iterator is n.
func NewFromFuncIterations ¶
NewFromFuncIterations returns a new iterator that yields the values returned by the given function. The function takes the current iteration number as an argument. The length of the iterator is n.
func NewFromFuncIterations2 ¶
NewFromFuncIterations2 returns a new iterator that yields the key-value pairs returned by the given function. The function takes the current iteration number as an argument. The length of the iterator is n.
func NewFromMap ¶
func NewFromMap[K comparable, V any](m map[K]V) iter.Seq2[K, V]
NewFromMap returns a new iterator that yields the key-value pairs of the given map.
func NewFromRepeat ¶
NewFromRepeat returns a new iterator that yields the same value a given number of times.
func NewFromSlice ¶
NewFromSlice returns a new iterator that yields the elements of the given slice.
func NewFromSlice2 ¶
NewFromSlice2 returns a new iterator that yields the key-value pairs of the given slice, where keys are the indices of the elements.
func None ¶
None returns true if none of the elements in the iter satisfy the predicate and false otherwise. It returns false at the first element that satisfies the predicate, and does not check the rest of the elements. If the iter is empty, it returns true. If the iter is nil, it panics.
func None2 ¶
func None2[K comparable, V any](iter iter.Seq2[K, V], predicate Predicate2[K, V]) bool
None2 returns true if none of the key-value pairs in the iter satisfy the predicate and false otherwise. It returns false at the first element that satisfies the predicate, and does not check the rest of the elements. If the iter is empty, it returns true. If the iter is nil, it panics.
func Product ¶
Product returns the product of all elements in the iter. If the iter is nil, it panics.
func Product2 ¶
func Product2[K comparable, V types.Number](iter iter.Seq2[K, V]) V
Product2 returns the product of all values in the iter. If the iter is nil, it panics.
func Reduce ¶
Reduce applies the function to each element in the iter and returns the accumulated value. If the iter is nil, it panics.
func Reduce2 ¶
func Reduce2[K comparable, V any](iter iter.Seq2[K, V], f func(V, V, K) V, initialValue V) V
Reduce2 applies the function to each key-value pair in the iter and returns the accumulated value. If the iter is nil, it panics.
func RemoveKey ¶
RemoveKey returns a new iterator with the key-value pairs of the input iterator, removing the element with the given key. If the input iterator is nil, it panics.
func RemoveNth ¶
RemoveNth returns a new iterator with the elements of the input iterator, removing the element at the given index. If the input iterator is nil, it panics. If the index is out of bounds, the result will be the same as the input iterator.
func Skip ¶
Skip returns a new iterator with the elements of the input iterator, skipping the first n elements. If the input iterator is nil, it panics. If n is greater than the length of the input iterator, the result will be an empty iterator.
func Skip2 ¶
Skip2 returns a new iterator with the key-value pairs of the input iterator, skipping the first n elements. If the input iterator is nil, it panics. If n is greater than the length of the input iterator, the result will be an empty iterator.
func Sort ¶
Sort sorts the elements of the input iterator and returns a new iterator with the sorted elements. If the input iterator is nil, it panics.
func Sort2 ¶
func Sort2[K comparable, V cmp.Ordered](iter iter.Seq2[K, V], less func(K, V, K, V) bool) iter.Seq2[K, V]
Sort2 sorts the key-value pairs of the input iterator and returns a new iterator with the sorted key-value pairs. If the input iterator is nil, it panics.
func Split ¶
Split splits the elements of the input iterator into smaller iterators, based on the given predicate. If the input iterator is nil, it panics.
func Split2 ¶
func Split2[K comparable, V any](i iter.Seq2[K, V], predicate func(K, V) bool) iter.Seq[iter.Seq2[K, V]]
Split2 splits the key-value pairs of the input iterator into smaller iterators, based on the given predicate. If the input iterator is nil, it panics.
func Sum2 ¶
func Sum2[K comparable, V types.Summable](iter iter.Seq2[K, V]) V
Sum2 returns the sum of all values in the iter. If the iter is nil, it panics.
func Swap ¶
Swap swaps the elements at the given indices in the input iterator. If the input iterator is nil, it panics. If the indices are out of bounds, it panics.
func Swap2 ¶
Swap2 swaps the key-value pairs at the given indices in the input iterator. If the input iterator is nil, it panics. If the indices are out of bounds, it panics.
func SwapByKey ¶
SwapByKey swaps the values of the key-value pairs with the given keys in the input iterator. If the input iterator is nil, it panics. If the keys are not present in the input iterator, it panics.
func ToMap ¶
func ToMap[K comparable, V any](iter iter.Seq2[K, V]) map[K]V
ToMap collects the key-value pairs of the given iterator into a map. If the iterator is infinite, this function will not return. If the iterator is nil, this function will panic.
func ToMapN ¶
func ToMapN[K comparable, V any](iter iter.Seq2[K, V], n uint) map[K]V
ToMapN collects the first n key-value pairs of the given iterator into a map. If n is greater than the length of the iterator, this function will return the whole iterator. If the iterator is nil, this function will panic.
func ToSlice ¶
ToSlice collects the elements of the given iterator into a slice. If the iterator is infinite, this function will not return. If the iterator is nil, this function will panic.
func ToSlice2 ¶
ToSlice2 collects the key-value pairs of the given iterator into a slice. The keys will be the indices of the elements. If the iterator is infinite, this function will not return. If the iterator is nil, this function will panic.
func ToSliceN ¶
ToSliceN collects the first n elements of the given iterator into a slice. If n is greater than the length of the iterator, the function will return the whole iterator. If the iterator is nil, this function will panic.
func Values ¶
Values returns a new iterator with the values of the input iterator. If the input iterator is nil, it panics.
Types ¶
type Predicate2 ¶
type Predicate2[K comparable, V any] func(K, V) bool
Predicate2 is a function that takes a key and a value and returns a boolean