ih

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alternate

func Alternate[V any](seqs ...iter.Seq[V]) iter.Seq[V]

Alternate returns an iterator that yields alternatively each seq from head to tail. The first exhausted seq stops the iterator.

func Alternate2

func Alternate2[K, V any](seqs ...iter.Seq2[K, V]) iter.Seq2[K, V]

Alternate returns an iterator that yields alternatively each seq from head to tail. The first exhausted seq stops the iterator.

func AppendSeq2

func AppendSeq2[S ~[]KeyValue[K, V], K, V any](s S, seq iter.Seq2[K, V]) S

AppendSeq2 appends the values from seq to the KeyValue slice and returns the extended slice.

func Chan

func Chan[V any](ch <-chan V, f func()) iter.Seq[V]

Chan returns an iterator over ch. Only closing ch stops the iterator.

func Chunk

func Chunk[S ~[]E, E any](s S, n int) iter.Seq[S]

Chunk returns an iterator over non overlapping sub-slices of n size.

func CollectString

func CollectString(seq iter.Seq[string], sizeHint int) string

CollectString reduces seq to a single string. sizeHint hints size of internal buffer. Correctly sized sizeHint may reduce allocation.

func Combine

func Combine[K, V any](seq1 iter.Seq[K], seq2 iter.Seq[V]) iter.Seq2[K, V]

Combine combines seq1 and seq2 into single key-value pairs.

func Decorate

func Decorate[V any](seq iter.Seq[V], prepend, append Iterable[V]) iter.Seq[V]

Decorate decorates seq by prepend and append, by yielding additional elements before and after seq yields.

func Decorate2

func Decorate2[K, V any](seq iter.Seq2[K, V], prepend, append Iterable2[K, V]) iter.Seq2[K, V]

Decorate2 decorates seq by prepend and append, by yielding additional elements before and after seq yields.

func Enumerate

func Enumerate[T any](seq iter.Seq[T]) iter.Seq2[int, T]

Enumerate wraps seq so that former part of paired values has an index starting from 0. Each time values are yielded index is increased by 1.

func Flatten

func Flatten[S ~[]E, E any](seq iter.Seq[S]) iter.Seq[E]

Flatten returns an iterator over slices yielded from seq.

func FlattenF

func FlattenF[S1 ~[]E1, E1 any, E2 any](i iter.Seq2[S1, E2]) iter.Seq2[E1, E2]

FlattenF returns an iterator over pairs of slice and non-slice. While iterating over slices, the latter part of pair is repeated.

func FlattenL

func FlattenL[S2 ~[]E2, E1 any, E2 any](i iter.Seq2[E1, S2]) iter.Seq2[E1, E2]

FlattenL returns an iterator over pairs of non-slice and slice. While iterating over slices, the former part of pair is repeated.

func Heap

func Heap[T any](h heap.Interface) iter.Seq[T]

Heap returns an iterator over heap.Interface. Consuming iter.Seq[T] also consumes h. Explicit closing is needed if h needs not to be mutated.

func LimitUntil

func LimitUntil[V any](seq iter.Seq[V], f func(V) bool) iter.Seq[V]

LimitUntil returns an iterator over seq that yields until f returns false.

func LimitUntil2

func LimitUntil2[K, V any](seq iter.Seq2[K, V], f func(K, V) bool) iter.Seq2[K, V]

LimitUntil2 returns an iterator over seq that yields until f returns false.

func ListAll

func ListAll[T any](l *list.List) iter.Seq[T]

ListAll returns an iterator over l.

func ListBackward

func ListBackward[T any](l *list.List) iter.Seq[T]

ListBackward returns an iterator over l, traversing it backward by calling Back and Prev.

func Omit

func Omit[K any](seq iter.Seq[K]) func(yield func() bool)

Omit returns an iterator over seq but drops data seq yields.

func Omit2

func Omit2[K, V any](seq iter.Seq2[K, V]) func(yield func() bool)

Omit2 returns an iterator over seq but drops data seq yields.

func OmitF

func OmitF[T, U any](i iter.Seq2[T, U]) iter.Seq[U]

OmitF drops former part of key-value pairs that seq generates.

func OmitL

func OmitL[T, U any](i iter.Seq2[T, U]) iter.Seq[T]

OmitL drops latter part of key-value pairs that seq generates.

func Range

func Range[T Numeric](start, end T) iter.Seq[T]

Range produces an iterator that yields sequential Numeric values in range [start, end). Values start from `start` and steps toward `end` 1 by 1, increased or decreased depending on start < end or not.

func RingAll

func RingAll[T any](r *ring.Ring) iter.Seq[T]

Ring returns an iterator over r. by traversing from r and consecutively calling Next.

func RingBackward

func RingBackward[T any](r *ring.Ring) iter.Seq[T]

RingBackward returns an iterator over r, traversing it backward starting from r and consecutively calling Prev.

func Scan

func Scan(scanner *bufio.Scanner) iter.Seq2[string, error]

Scanner wraps scanner with an iterator over scanned text.

func Skip

func Skip[V any](seq iter.Seq[V], n int) iter.Seq[V]

SkipWhile returns an iterator over seq that skips n elements from seq.

func Skip2

func Skip2[K, V any](seq iter.Seq2[K, V], n int) iter.Seq2[K, V]

SkipWhile returns an iterator over seq that skips n key-value pairs from seq.

func SkipWhile

func SkipWhile[V any](seq iter.Seq[V], f func(V) bool) iter.Seq[V]

SkipWhile returns an iterator over seq that skips elements until f returns false.

func SkipWhile2

func SkipWhile2[K, V any](seq iter.Seq2[K, V], f func(K, V) bool) iter.Seq2[K, V]

SkipWhile2 returns an iterator over seq that skips key-value pairs until f returns false.

func StringChunk

func StringChunk(s string, n int) iter.Seq[string]

StringChunk returns an iterator over non overlapping sub strings of n bytes. Sub slicing may cut in mid of utf8 sequences.

func StringRuneChunk

func StringRuneChunk(s string, n int) iter.Seq[string]

StringRuneChunk returns an iterator over non overlapping sub strings of n utf8 characters.

func SyncMap

func SyncMap[K, V any](m *sync.Map) iter.Seq2[K, V]

SyncMap returns an iterator over m. Breaking Seq2 may stop producing more data, however it may still be O(N).

func Transpose

func Transpose[K, V any](seq iter.Seq2[K, V]) iter.Seq2[V, K]

Transpose returns an iterator over seq that yields K and V reversed.

func Window

func Window[S ~[]E, E any](s S, n int) iter.Seq[S]

Window returns an iterator over overlapping sub-slices of n size (moving windows).

Types

type FuncIterable

type FuncIterable[V any] func() iter.Seq[V]

func (FuncIterable[V]) IntoIter

func (f FuncIterable[V]) IntoIter() iter.Seq[V]

func (FuncIterable[V]) Iter

func (f FuncIterable[V]) Iter() iter.Seq[V]

type FuncIterable2

type FuncIterable2[K, V any] func() iter.Seq2[K, V]

func (FuncIterable2[K, V]) IntoIter2

func (f FuncIterable2[K, V]) IntoIter2() iter.Seq2[K, V]

func (FuncIterable2[K, V]) Iter2

func (f FuncIterable2[K, V]) Iter2() iter.Seq2[K, V]

type IntoIterable

type IntoIterable[V any] interface {
	IntoIter() iter.Seq[V]
}

IntoIterable wraps basic IntoIter2 method.

Calling IntoIter may mutate underlying state. Therefore calling the method again may also not yield same result.

type IntoIterable2

type IntoIterable2[K, V any] interface {
	IntoIter2() iter.Seq2[K, V]
}

IntoIterable2 wraps basic IntoIter2 method.

Calling IntoIter2 may mutate underlying state. Therefore calling the method again may also not yield same result.

type Iterable

type Iterable[V any] interface {
	Iter() iter.Seq[V]
}

Iterable wraps basic Iter method.

Iter should always return iterators that yield same set of data.

type Iterable2

type Iterable2[K, V any] interface {
	Iter2() iter.Seq2[K, V]
}

Iterable2 wraps basic Iter2 method.

Iter2 should always return iterators that yield same set of data.

type KeyValue

type KeyValue[K, V any] struct {
	K K
	V V
}

func Collect2

func Collect2[K, V any](seq iter.Seq2[K, V]) []KeyValue[K, V]

Collect2 collects values from seq into a new KeyValue slice and returns it.

type KeyValues

type KeyValues[K, V any] []KeyValue[K, V]

KeyValues adds the Iter2 method to slice of KeyValue-s.

func (KeyValues[K, V]) Iter2

func (v KeyValues[K, V]) Iter2() iter.Seq2[K, V]

type Numeric

type Numeric interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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