iterable

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chan

type Chan[V any] <-chan V

Chan adds IntoIter method to a receive only channel.

func (Chan[V]) IntoIter

func (c Chan[V]) IntoIter() iter.Seq[V]

type Heap

type Heap[T any] struct {
	heap.Interface
}

Heap adds IntoIter method to a heap.Interface.

func (Heap[T]) IntoIter

func (h Heap[T]) IntoIter() iter.Seq[T]

type List

type List[T any] struct {
	*list.List
}

List adds Iter method to *list.List.

func (List[T]) Iter

func (l List[T]) Iter() iter.Seq[T]

type ListBackward

type ListBackward[T any] struct {
	*list.List
}

ListBackward adds Iter method to *list.List. Iter returns an iterator that traverses list backward.

func (ListBackward[T]) Iter

func (l ListBackward[T]) Iter() iter.Seq[T]

type MapAll

type MapAll[K comparable, V any] map[K]V

MapAll adds Iter2 method to map[K]V that merely calling maps.All.

func (MapAll[K, V]) Iter2

func (m MapAll[K, V]) Iter2() iter.Seq2[K, V]

type MapSorted

type MapSorted[K cmp.Ordered, V any] map[K]V

MapSorted adds Iter2 to map[K]V where K is basic ordered type. Iter2 takes snapshot of keys and sort it in ascending order, then returns an iterator over pairs of the keys and values that corresponds to the key.

func (MapSorted[K, V]) Iter2

func (m MapSorted[K, V]) Iter2() iter.Seq2[K, V]

type MapSortedFunc

type MapSortedFunc[M ~map[K]V, K comparable, V any] struct {
	M   M
	Cmp func(K, K) int
}

MapSortedFunc adds Iter2 to map[K]V. Iter2 takes snapshot of keys and sort it using the comparison function, then returns an iterator over pairs of the keys and values that corresponds to the key.

func (MapSortedFunc[M, K, V]) Iter2

func (m MapSortedFunc[M, K, V]) Iter2() iter.Seq2[K, V]

type Range

type Range[T hiter.Numeric] struct {
	Start, End T
}

Range adds Iter method to the pair of 2 Numeric values.

func (Range[T]) Iter

func (r Range[T]) Iter() iter.Seq[T]

Iter returns 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.

type Repeatable

type Repeatable[V any] struct {
	V V
	N int
}

Repeatable generates an iterator that generates V N times.

func (Repeatable[V]) Iter

func (r Repeatable[V]) Iter() iter.Seq[V]

type Repeatable2

type Repeatable2[K, V any] struct {
	K K
	V V
	N int
}

Repeatable2 generates an iterator that generates pairs of K and V N times.

func (Repeatable2[K, V]) Iter2

func (r Repeatable2[K, V]) Iter2() iter.Seq2[K, V]

type RepeatableFunc added in v0.0.3

type RepeatableFunc[V any] struct {
	FnV func() V
	N   int
}

RepeatableFunc generates an iterator that generates value returned from FnV N times.

func (RepeatableFunc[V]) Iter added in v0.0.3

func (r RepeatableFunc[V]) Iter() iter.Seq[V]

type RepeatableFunc2 added in v0.0.3

type RepeatableFunc2[K, V any] struct {
	FnK func() K
	FnV func() V
	N   int
}

RepeatableFunc2 generates an iterator that generates pairs of value that FnK and FnV return N times.

func (RepeatableFunc2[K, V]) Iter2 added in v0.0.3

func (r RepeatableFunc2[K, V]) Iter2() iter.Seq2[K, V]

type Ring

type Ring[T any] struct {
	*ring.Ring
}

Ring adds Iter method to *ring.Ring.

func (Ring[T]) Iter

func (r Ring[T]) Iter() iter.Seq[T]

type RingBackward

type RingBackward[T any] struct {
	*ring.Ring
}

Ring adds Iter method to *ring.Ring. Iter returns an iterator that traverses ring backward.

func (RingBackward[T]) Iter

func (r RingBackward[T]) Iter() iter.Seq[T]

type Scanner

type Scanner struct {
	*bufio.Scanner
}

func (Scanner) IntoIter2

func (s Scanner) IntoIter2() iter.Seq2[string, error]

type SliceAll

type SliceAll[E any] []E

SliceAll adds Iter and Iter2 methods to slice of any element E. They merely call slices.Values, slices.All respectively.

func (SliceAll[E]) Iter

func (s SliceAll[E]) Iter() iter.Seq[E]

func (SliceAll[E]) Iter2

func (s SliceAll[E]) Iter2() iter.Seq2[int, E]

type SliceBackward

type SliceBackward[E any] []E

SliceBackward adds Iter and Iter2 methods to slice of any element E. They return iterators over []E traversing them backward with descending indices.

func (SliceBackward[E]) Iter

func (s SliceBackward[E]) Iter() iter.Seq[E]

func (SliceBackward[E]) Iter2

func (s SliceBackward[E]) Iter2() iter.Seq2[int, E]

type SyncMap

type SyncMap[K comparable, V any] struct {
	*sync.Map
}

SyncMap adds Iter2 method that merely calls sync.Map.Range.

func (SyncMap[K, V]) Iter2

func (s SyncMap[K, V]) Iter2() iter.Seq2[K, V]

Jump to

Keyboard shortcuts

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