Documentation ¶
Overview ¶
Package itkit provides short, dead simple and concise type-safe generic iterator interfaces for Go. With a few extras similar to what Python has to offer.
Piece of advice ¶
Abandon Hope All Ye Who Enter Here.
This Go Module is probably a collection of anti-patterns. It started as an experiment about what can be done with the new Go generics functionality that was introduced into go in the 1.18 version, although I personally like how this module turned out to be.
My recommendation for now would be to use it sparingly and use normal Go iteration with the for keyword where possible and only use itkit iterators where it makes sense to reduce code and complexity without sacrificing readability.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[T any] interface { // Next advances the iterator to the first/next item, // returning true if successful meaning there is an item // available to be fetched with Value and false otherwise. Next() bool // Value returns the current item if there is any and may // panic otherwise. // // Note: Use Next to ensure there is an item. Value() T }
An Iterator allows consuming individual items in a stream of items.
Directories ¶
Path | Synopsis |
---|---|
_example
|
|
internal
|
|
iters
|
|
chanit
Package chanit allows for native Go channels to be used with iterators.
|
Package chanit allows for native Go channels to be used with iterators. |
funcit
Package funcit allows for functional sources of items to be used with iterators.
|
Package funcit allows for functional sources of items to be used with iterators. |
genit
Package genit allows for stateful running goroutines to be used with iterators.
|
Package genit allows for stateful running goroutines to be used with iterators. |
mapit
Package mapit allows for native Go maps to be used with iterators.
|
Package mapit allows for native Go maps to be used with iterators. |
rangeit
Package rangeit allows to iterate over a range of numbers.
|
Package rangeit allows to iterate over a range of numbers. |
runeit
Package runeit allows for native Go runes to be used with iterators.
|
Package runeit allows for native Go runes to be used with iterators. |
sliceit
Package sliceit allows for native Go slices to be used with iterators.
|
Package sliceit allows for native Go slices to be used with iterators. |
valit
Package valit allows for native Go values to be used with iterators.
|
Package valit allows for native Go values to be used with iterators. |
Package itlib provides generic function for operating on iterators.
|
Package itlib provides generic function for operating on iterators. |