Documentation
¶
Overview ¶
Package irt (for IteratoRTools), provides a collection of stateless iterator handling functions, with zero dependencies on other fun packages.
Index ¶
- func Append[T any](seq iter.Seq[T], with ...T) iter.Seq[T]
- func Apply[T any, OP ~func(T)](seq iter.Seq[T], op OP) (count int)
- func Apply2[A, B any, OP ~func(A, B)](seq iter.Seq2[A, B], op OP) (count int)
- func ApplyAll[T any, OP ~func(T) error](seq iter.Seq[T], op OP) error
- func ApplyAll2[A, B any, OP ~func(A, B) error](seq iter.Seq2[A, B], op OP) error
- func ApplyUnless[T any, OP ~func(T) bool](seq iter.Seq[T], op OP) int
- func ApplyUnless2[A, B any, OP ~func(A, B) bool](seq iter.Seq2[A, B], op OP) int
- func ApplyUntil[T any, OP ~func(T) error](seq iter.Seq[T], op OP) error
- func ApplyUntil2[A, B any, OP ~func(A, B) error](seq iter.Seq2[A, B], op OP) error
- func ApplyWhile[T any, OP ~func(T) bool](seq iter.Seq[T], op OP) (count int)
- func ApplyWhile2[A, B any, OP ~func(A, B) bool](seq iter.Seq2[A, B], op OP) (count int)
- func Args[T any](items ...T) iter.Seq[T]
- func AsGenerator[T any](seq iter.Seq[T]) func(context.Context) (T, bool)
- func Chain[T any](seq iter.Seq[iter.Seq[T]]) iter.Seq[T]
- func Chain2[A, B any](seq iter.Seq[iter.Seq2[A, B]]) iter.Seq2[A, B]
- func ChainMaps[A comparable, B any, M ~map[A]B](seq iter.Seq[M]) iter.Seq2[A, B]
- func ChainSlices[T any, S ~[]T](seq iter.Seq[S]) iter.Seq[T]
- func Channel[T any](ctx context.Context, ch <-chan T) iter.Seq[T]
- func Chunk[T any](seq iter.Seq[T], num int) iter.Seq[iter.Seq[T]]
- func Collect[T any](seq iter.Seq[T], args ...int) (s []T)
- func Collect2[K comparable, V any](seq iter.Seq2[K, V], args ...int) map[K]V
- func CollectFirstN[T any](seq iter.Seq[T], n int) []T
- func Contains[T comparable](seq iter.Seq[T], cmp T) (ok bool)
- func Convert[A, B any, OP ~func(A) B](seq iter.Seq[A], op OP) iter.Seq[B]
- func Convert2[A, B, C, D any, OP ~func(A, B) (C, D)](seq iter.Seq2[A, B], op OP) iter.Seq2[C, D]
- func Count[T any](seq iter.Seq[T]) (size int)
- func Count2[A, B any](seq iter.Seq2[A, B]) (size int)
- func Deref[T any](seq iter.Seq[*T]) iter.Seq[T]
- func DerefWithZeros[T any](seq iter.Seq[*T]) iter.Seq[T]
- func Equal[T comparable](rh iter.Seq[T], lh iter.Seq[T]) bool
- func First[A, B any](seq iter.Seq2[A, B]) iter.Seq[A]
- func FirstValue[T any](seq iter.Seq[T]) (zero T, ok bool)
- func FirstValue2[A, B any](seq iter.Seq2[A, B]) (azero A, bzero B, ok bool)
- func Flip[A, B any](seq iter.Seq2[A, B]) iter.Seq2[B, A]
- func ForEach[T any, OP ~func(T)](seq iter.Seq[T], op OP) iter.Seq[T]
- func ForEach2[A, B any, OP ~func(A, B)](seq iter.Seq2[A, B], op OP) iter.Seq2[A, B]
- func ForEachWhile[T any, OP func(T) bool](seq iter.Seq[T], op OP) iter.Seq[T]
- func ForEachWhile2[A, B any, OP ~func(A, B) bool](seq iter.Seq2[A, B], op OP) iter.Seq2[A, B]
- func Generate[T any, OP ~func() T](op OP) iter.Seq[T]
- func Generate2[A, B any, OP ~func() (A, B)](op OP) iter.Seq2[A, B]
- func GenerateN[T any, OP ~func() T](num int, op OP) iter.Seq[T]
- func GenerateOk[T any, OP ~func() (T, bool)](gen OP) iter.Seq[T]
- func GenerateOk2[A, B any, OP ~func() (A, B, bool)](gen OP) iter.Seq2[A, B]
- func GenerateWhile[T any, OP ~func() T, CHECK ~func(T) bool](op OP, while CHECK) iter.Seq[T]
- func GenerateWhile2[A, B any, OP ~func() (A, B), WHILE ~func(A, B) bool](op OP, while WHILE) iter.Seq2[A, B]
- func Group[K comparable, V any](seq iter.Seq2[K, V]) iter.Seq2[K, []V]
- func GroupBy[K comparable, V any](seq iter.Seq[V], groupBy func(V) K) iter.Seq2[K, []V]
- func Index[T any](seq iter.Seq[T]) iter.Seq2[int, T]
- func Join[T any](seqs ...iter.Seq[T]) iter.Seq[T]
- func Join2[A, B any](seqs ...iter.Seq2[A, B]) iter.Seq2[A, B]
- func JoinErrors(seq iter.Seq[error]) error
- func KVapply[A, B any](seq iter.Seq[KV[A, B]], op func(A, B))
- func KVargs[A, B any](elems ...KV[A, B]) iter.Seq2[A, B]
- func KVcmp[A, B cmp.Ordered](lh, rh KV[A, B]) int
- func KVcmpFirst[A cmp.Ordered, B any](lh, rh KV[A, B]) int
- func KVcmpSecond[A any, B cmp.Ordered](l, r KV[A, B]) int
- func KVjoin[A, B any](seq iter.Seq2[A, B]) iter.Seq[KV[A, B]]
- func KVmap[A comparable, B any, M ~map[A]B](in M) iter.Seq[KV[A, B]]
- func KVsplit[A, B any](seq iter.Seq[KV[A, B]]) iter.Seq2[A, B]
- func Keep[T any](seq iter.Seq[T], prd func(T) bool) iter.Seq[T]
- func Keep2[A, B any](seq iter.Seq2[A, B], prd func(A, B) bool) iter.Seq2[A, B]
- func KeepErrors(seq iter.Seq[error]) iter.Seq[error]
- func KeepOk[T any](seq iter.Seq2[T, bool]) iter.Seq[T]
- func Limit[T any](seq iter.Seq[T], n int) iter.Seq[T]
- func Limit2[A, B any](seq iter.Seq2[A, B], n int) iter.Seq2[A, B]
- func Map[K comparable, V any, M ~map[K]V](mp M) iter.Seq2[K, V]
- func MapKV[A comparable, B any, M ~map[A]B](mp M) iter.Seq[KV[A, B]]
- func Merge[A, B, C any, OP ~func(A, B) C](seq iter.Seq2[A, B], op OP) iter.Seq[C]
- func Modify[T any, OP ~func(T) T](seq iter.Seq[T], op OP) iter.Seq[T]
- func Modify2[A, B any, OP ~func(A, B) (A, B)](seq iter.Seq2[A, B], op OP) iter.Seq2[A, B]
- func ModifyAll[T any, OP ~func(T) T](seq iter.Seq[T], ops ...OP) iter.Seq[T]
- func ModifyAll2[A, B any](seq iter.Seq2[A, B], ops ...func(A, B) (A, B)) iter.Seq2[A, B]
- func Monotonic() iter.Seq[int]
- func MonotonicFrom(start int) iter.Seq[int]
- func One[T any](v T) iter.Seq[T]
- func Pipe[T any](ctx context.Context, seq iter.Seq[T]) <-chan T
- func Ptrs[T any](seq iter.Seq[T]) iter.Seq[*T]
- func PtrsWithNils[T comparable](seq iter.Seq[T]) iter.Seq[*T]
- func Range(start int, end int) iter.Seq[int]
- func ReadLines(reader io.Reader) iter.Seq[string]
- func ReadLinesErr(reader io.Reader) iter.Seq2[string, error]
- func Reduce[A, B any](seq iter.Seq[A], rfn func(B, A) B) (out B)
- func Reduce2[A, B, C any](seq iter.Seq2[A, B], rfn func(C, A, B) C) (out C)
- func Remove[T any](seq iter.Seq[T], prd func(T) bool) iter.Seq[T]
- func Remove2[A, B any](seq iter.Seq2[A, B], prd func(A, B) bool) iter.Seq2[A, B]
- func RemoveErrors[T any](seq iter.Seq2[T, error]) iter.Seq[T]
- func RemoveNils[T any](seq iter.Seq[*T]) iter.Seq[*T]
- func RemoveZeros[T comparable](seq iter.Seq[T]) iter.Seq[T]
- func Resolve[T any, F ~func() T](seq iter.Seq[F]) iter.Seq[T]
- func Resolve2[A, B any, F ~func() (A, B)](seq iter.Seq[F]) iter.Seq2[A, B]
- func ResolveWrap[A, B any, F ~func(A) B](seq iter.Seq[F], wrapping A) iter.Seq[B]
- func ResolveWrap2[A, B, C any, F ~func(A) (B, C)](seq iter.Seq[F], wrapping A) iter.Seq2[B, C]
- func RunAll[OP ~func()](seq iter.Seq[OP]) (count int)
- func Second[A, B any](seq iter.Seq2[A, B]) iter.Seq[B]
- func Shard[T any](ctx context.Context, num int, seq iter.Seq[T]) iter.Seq[iter.Seq[T]]
- func Slice[T any, S ~[]T](sl S) iter.Seq[T]
- func SortBy[K cmp.Ordered, T any](seq iter.Seq[T], cf func(T) K) iter.Seq[T]
- func SortBy2[K cmp.Ordered, A, B any](seq iter.Seq2[A, B], cf func(A, B) K) iter.Seq2[A, B]
- func Two[A, B any](a A, b B) iter.Seq2[A, B]
- func Unique[T comparable](seq iter.Seq[T]) iter.Seq[T]
- func UniqueBy[K comparable, V any](seq iter.Seq[V], kfn func(V) K) iter.Seq[V]
- func Until[T any](seq iter.Seq[T], prd func(T) bool) iter.Seq[T]
- func Until2[A, B any](seq iter.Seq2[A, B], is func(A, B) bool) iter.Seq2[A, B]
- func UntilError[T any](seq iter.Seq2[T, error]) iter.Seq[T]
- func UntilNil[T any](seq iter.Seq[*T]) iter.Seq[T]
- func While[T any](seq iter.Seq[T], prd func(T) bool) iter.Seq[T]
- func While2[A, B any](seq iter.Seq2[A, B], prd func(A, B) bool) iter.Seq2[A, B]
- func WhileOk[T any](seq iter.Seq2[T, bool]) iter.Seq[T]
- func WhileSuccess[T any](seq iter.Seq2[T, error]) iter.Seq[T]
- func With[A, B any, OP ~func(A) B](seq iter.Seq[A], op OP) iter.Seq2[A, B]
- func With2[A, B, C any, OP ~func(A) (B, C)](seq iter.Seq[A], op OP) iter.Seq2[B, C]
- func With3[A, B, C any, OP ~func(A) (B, C)](seq iter.Seq[A], op OP) iter.Seq2[KV[A, B], C]
- func WithBuffer[T any](ctx context.Context, seq iter.Seq[T], size int) iter.Seq[T]
- func WithEach[A, B any, OP ~func() B](seq iter.Seq[A], op OP) iter.Seq2[A, B]
- func WithHooks[T any](seq iter.Seq[T], before func(), after func()) iter.Seq[T]
- func WithMutex[T any](seq iter.Seq[T], mtx *sync.Mutex) iter.Seq[T]
- func WithMutex2[A, B any](seq iter.Seq2[A, B], mtx *sync.Mutex) iter.Seq2[A, B]
- func WithSetup[T any](seq iter.Seq[T], setup func()) iter.Seq[T]
- func Zip[A, B any](rh iter.Seq[A], lh iter.Seq[B]) iter.Seq2[A, B]
- type KV
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
Append returns a sequence containing all elements from the input sequence followed by additional values provided.
func Apply ¶
Apply consumes the sequence and calls op for each element. Returns the number of elements processed.
func Apply2 ¶
Apply2 consumes the iterator and calls op for each pair. Returns the number of pairs processed.
func ApplyAll ¶
ApplyAll consumes the sequence and calls op for each element. It collects all errors returned by op and returns them joined.
func ApplyAll2 ¶
ApplyAll2 consumes the iterator and calls op for each pair. It collects all errors returned by op and returns them joined.
func ApplyUnless ¶
ApplyUnless consumes the sequence and calls op for each element. Iteration stops if op returns true. Returns the number of elements processed.
func ApplyUnless2 ¶
ApplyUnless2 consumes the iterator and calls op for each pair. Iteration stops if op returns true. Returns the number of pairs processed.
func ApplyUntil ¶
ApplyUntil consumes the sequence and calls op for each element. Iteration stops if op returns an error. Returns the error from op, or nil if the sequence was fully consumed.
func ApplyUntil2 ¶
ApplyUntil2 consumes the iterator and calls op for each pair. Iteration stops if op returns an error. Returns the error from op, or nil if the sequence was fully consumed.
func ApplyWhile ¶
ApplyWhile consumes the sequence and calls op for each element. Iteration stops if op returns false. Returns the number of elements processed.
func ApplyWhile2 ¶
ApplyWhile2 consumes the iterator and calls op for each pair. Iteration stops if op returns false. Returns the number of pairs processed.
func AsGenerator ¶
AsGenerator provides in inverse of the GenerateOk operation: the function will yield values. When the boolean "ok" value is false the sequence has been exhausted.
func ChainSlices ¶
ChainSlices flattens a sequence of slices into a single sequence.
func Channel ¶
Channel returns a sequence that yields elements from the provided channel until the channel is closed or the context is canceled.
func Chunk ¶
Chunk returns a sequence of sequences, where each inner sequence contains at most num elements from the input sequence. If num <= 0, the sequence is empty.
func Collect ¶
Collect consumes the sequence and returns a slice of all elements. This combines the operations slices.Collect and make([]T).
Unlike you can only set the capacity, not the initial length. For compatibility, you can specify more than one integer arguments, though ONLY one can be non-zero. If you specify a capacity argument that is less than zero, it becomes zero.
func Collect2 ¶
func Collect2[K comparable, V any](seq iter.Seq2[K, V], args ...int) map[K]V
Collect2 consumes the sequence and returns a map with all elements. This combines the operations maps.Collect and make(map[K]V).
Like make(map[K]V), the optional args are args[0] sets initial length.
func CollectFirstN ¶
CollectFirstN consumes up to n elements from the sequence and returns them as a slice. If n <= 0, returns an empty slice.
func Contains ¶
func Contains[T comparable](seq iter.Seq[T], cmp T) (ok bool)
Contains returns true if the sequence contains an element equal to cmp. Iteration stops as soon as a match is found.
func Convert ¶
Convert returns a sequence where each element is the result of applying op to the elements of the input sequence.
func Convert2 ¶
Convert2 returns a iterator where each pair is the result of applying op to the pairs of the input iterator.
func Deref ¶
Deref returns a sequence of values dereferenced from the input sequence of pointers. Nil pointers in the input sequence are skipped.
func DerefWithZeros ¶
DerefWithZeros returns a sequence of values dereferenced from the input sequence of pointers. Nil pointers in the input sequence result in the zero value for the type.
func First ¶
First returns a sequence containing only the first element (key) of each pair in the input iterator.
func FirstValue ¶
FirstValue returns the first value from the sequence and true. If the sequence is empty, it returns the zero value and false.
func FirstValue2 ¶
FirstValue2 returns the first pair of values from the iterator and true. If the sequence is empty, it returns zero values and false.
func ForEach ¶
ForEach returns a sequence that calls op for each element of the input sequence during iteration.
func ForEach2 ¶
ForEach2 returns a iterator that calls op for each pair of the input iterator during iteration.
func ForEachWhile ¶
ForEachWhile returns a sequence that calls op for each element of the input sequence. Iteration stops if op returns false.
func ForEachWhile2 ¶
ForEachWhile2 returns a iterator that calls op for each pair of the input iterator. Iteration stops if op returns false.
func GenerateN ¶
GenerateN returns a sequence that yields exactly num elements produced by calling op. If num <= 0, the sequence is empty.
func GenerateOk ¶
GenerateOk returns a sequence that yields values produced by gen as long as gen returns true.
func GenerateOk2 ¶
GenerateOk2 returns a iterator that yields pairs produced by gen as long as gen returns true.
func GenerateWhile ¶
GenerateWhile returns a sequence that yields values produced by op as long as they satisfy the while predicate.
func GenerateWhile2 ¶
func GenerateWhile2[A, B any, OP ~func() (A, B), WHILE ~func(A, B) bool](op OP, while WHILE) iter.Seq2[A, B]
GenerateWhile2 returns a iterator that yields pairs produced by op as long as they satisfy the while predicate.
func Group ¶
Group consumes the iterator and groups values by their keys into a iterator of keys and slices of values.
func GroupBy ¶
GroupBy consumes the sequence and groups elements into a iterator of keys and slices of values, using the groupBy function to determine the key for each element.
func Index ¶
Index returns a iterator where each element from the input sequence is paired with its 0-based index.
func Join ¶
Join concatenates multiple sequences into a single sequence, yielding all elements from each sequence in order.
func Join2 ¶
Join2 concatenates multiple pair sequences into a single pair sequence, yielding all key-value pairs from each sequence in order.
func JoinErrors ¶
JoinErrors consumes a sequence of errors and returns a single error produced by errors.Join. Returns nil if the sequence is empty.
func KVcmpFirst ¶
KVcmpFirst compares two Elem values by comparing only their First fields.
func KVcmpSecond ¶
KVcmpSecond compares two Elem values by comparing only their Second fields.
func KVmap ¶ added in v0.14.1
func KVmap[A comparable, B any, M ~map[A]B](in M) iter.Seq[KV[A, B]]
KVmap converts a map into a sequence of KV pairs, and returns them as an iterator.
func Keep ¶
Keep returns a sequence containing only the elements from the input sequence that satisfy the predicate prd.
func Keep2 ¶
Keep2 returns a iterator containing only the pairs from the input iterator that satisfy the predicate prd.
func KeepErrors ¶
KeepErrors returns a sequence containing only the non-nil errors from the input sequence.
func KeepOk ¶
KeepOk returns a sequence containing only the values from pairs where the boolean is true.
func Limit ¶
Limit returns a sequence that yields at most n elements from the input sequence. If n <= 0, the sequence is empty.
func Limit2 ¶
Limit2 returns a iterator that yields at most n pairs from the input iterator. If n <= 0, the sequence is empty.
func Map ¶
func Map[K comparable, V any, M ~map[K]V](mp M) iter.Seq2[K, V]
Map returns a iterator containing all key-value pairs from the map.
func MapKV ¶ added in v0.14.1
func MapKV[A comparable, B any, M ~map[A]B](mp M) iter.Seq[KV[A, B]]
MapKV transforms a map into an iterator of KV pairs.
func Merge ¶
Merge returns a sequence where each element is the result of applying op to the pairs of the input iterator.
func Modify ¶
Modify applies a transformation function to each element in the sequence. If the operation is nil, the sequence is returned unchanged.
func Modify2 ¶
Modify2 applies a transformation function to each pair in the sequence. If the operation is nil, the sequence is returned unchanged.
func ModifyAll ¶
ModifyAll applies a sequence of transformation functions to each element in the sequence. Nil modification functions are skipped. Each transformation is applied in order, with the result of one transformation passed to the next.
func ModifyAll2 ¶
ModifyAll2 applies a sequence of transformation functions to each pair in the sequence. Nil functions are filtered out and skipped. Each transformation is applied in order, with the result of one transformation passed to the next.
func MonotonicFrom ¶
MonotonicFrom returns an infinite sequence of integers starting from start.
func Pipe ¶
Pipe returns a channel that receives all elements from the input sequence. The channel is closed when the sequence is exhausted or the context is canceled.
func Ptrs ¶
Ptrs returns a sequence where each element is a pointer to the value in the input sequence.
func PtrsWithNils ¶
func PtrsWithNils[T comparable](seq iter.Seq[T]) iter.Seq[*T]
PtrsWithNils returns a sequence of pointers to the values in the input sequence. If a value is the zero value for its type, a nil pointer is produced instead.
func ReadLines ¶
ReadLines returns a sequence of strings from the reader, stopping at the first error.
func ReadLinesErr ¶
ReadLinesErr returns a iterator of strings and errors from the reader. It yields each line with a nil error, and finally yields an empty string and the scanner's error.
func Reduce ¶
Reduce consumes the sequence and reduces it to a single value by repeatedly applying rfn.
func Reduce2 ¶ added in v0.14.1
Reduce2 consumes a sequence o pairs and reduces it to a single value by repeatedly applying rfn.
func Remove ¶
Remove returns a sequence containing only the elements from the input sequence that do NOT satisfy the predicate prd.
func Remove2 ¶
Remove2 returns a iterator containing only the pairs from the input iterator that do NOT satisfy the predicate prd.
func RemoveErrors ¶
RemoveErrors returns a sequence containing only the values from pairs where the error is nil.
func RemoveNils ¶
RemoveNils returns a sequence containing all non-nil pointers from the input sequence.
func RemoveZeros ¶
func RemoveZeros[T comparable](seq iter.Seq[T]) iter.Seq[T]
RemoveZeros returns a sequence containing all non-zero values from the input sequence.
func Resolve ¶ added in v0.14.2
Resolve returns a sequence that lazily executes each function in the input sequence and yields the results. Functions are only called during iteration.
func Resolve2 ¶ added in v0.14.2
Resolve2 returns a pair sequence that lazily executes each function in the input sequence and yields the result pairs. Functions are only called during iteration.
func ResolveWrap ¶ added in v0.14.2
ResolveWrap returns a sequence that lazily executes each function in the input sequence with the provided argument and yields the results. Functions are only called during iteration.
func ResolveWrap2 ¶ added in v0.14.2
ResolveWrap2 returns a pair sequence that lazily executes each function in the input sequence with the provided argument and yields the result pairs. Functions are only called during iteration.
func RunAll ¶
RunAll takes a sequences of nilary functions and runs them all, returning a count. If any functions are Nil. For other function types, and for nil/panic safety, use the operations in the wpa package.
func Second ¶
Second returns a sequence containing only the second element (value) of each pair in the input iterator.
func SortBy ¶
SortBy consumes the sequence, sorts it based on the keys produced by cf, and returns a new sequence of the sorted elements.
func SortBy2 ¶
SortBy2 consumes the iterator, sorts it based on the keys produced by cf, and returns a new iterator of the sorted pairs.
func Unique ¶
func Unique[T comparable](seq iter.Seq[T]) iter.Seq[T]
Unique returns a sequence containing only the first occurrence of each unique element from the input sequence.
func UniqueBy ¶
UniqueBy returns a sequence containing only the first occurrence of each element from the input sequence that produces a unique key when passed to kfn.
func Until ¶
Until returns a sequence that yields elements from the input sequence until the predicate prd returns true.
func Until2 ¶
Until2 returns a iterator that yields pairs from the input iterator until the predicate is returns true.
func UntilError ¶
UntilError returns a sequence of values from pairs, stopping when a non-nil error is encountered.
func UntilNil ¶
UntilNil returns a sequence of dereferenced values from the input sequence of pointers, stopping when a nil pointer is encountered.
func While ¶
While returns a sequence that yields elements from the input sequence as long as the predicate prd returns true.
func While2 ¶
While2 returns a iterator that yields pairs from the input iterator as long as the predicate prd returns true.
func WhileOk ¶
WhileOk returns a sequence that yields values from pairs as long as the boolean is true.
func WhileSuccess ¶
WhileSuccess returns a sequence that yields values from pairs as long as the error is nil.
func With ¶
With returns a iterator where each element from the input sequence is paired with the result of applying op to it.
func With2 ¶
With2 returns a iterator where each pair is produced by applying op to each element of the input sequence.
func With3 ¶
With3 returns a iterator where each pair is produced by applying op to each element of the input sequence.
func WithBuffer ¶
WithBuffer maintains a buffer of items read from the source iterator, waiting for downstream consumers of the output iterator, to consume them.
func WithEach ¶
WithEach returns a iterator where each element from the input sequence is paired with a value produced by calling op.
func WithHooks ¶
WithHooks returns a sequence that calls before() when iteration starts and after() when iteration ends. after() is called even if iteration stops early. Nil hooks are ignored.
func WithMutex ¶
WithMutex returns a sequence that synchronizes all calls to the underlying iterator using the provided mutex.
func WithMutex2 ¶
WithMutex2 returns a pair sequence that synchronizes all calls to the underlying iterator using the provided mutex.
Types ¶
type KV ¶
type KV[A, B any] struct { Key A Value B }
KV is a generic pair type that holds two values of potentially different types.
func WithKV ¶
WithKV creates a KV by applying a function to the first value to derive the second value.
func (KV[A, B]) Apply ¶
func (e KV[A, B]) Apply(op func(A, B))
Apply calls the provided function with the First and Second values of the Elem.
func (KV[A, B]) Compare ¶
Compare returns a comparator that compares both First and Second fields using the provided comparison functions.
func (KV[A, B]) CompareFirst ¶
CompareFirst returns a comparator that compares only the First field using the provided comparison function.
func (KV[A, B]) CompareSecond ¶
CompareSecond returns a comparator that compares only the Second field using the provided comparison function.