Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CountIter ¶
type CountIter struct {
// contains filtered or unexported fields
}
CountIter implements `Count`. See `Count`'s documentation.
type DropIter ¶
type DropIter[T any] struct { // contains filtered or unexported fields }
DropIter implements `Drop`. See `Drop`'s documentation.
func Drop ¶
Drop instantiates a `DropIter` that will skip the number of items of its wrapped iterator by the provided count.
Example ¶
package main
import (
"fmt"
"github.com/BooleanCat/go-functional/iter"
)
func main() {
counter := iter.Drop[int](iter.Count(), 2)
fmt.Println(counter.Next().Unwrap())
}
Output: 2
type ExhaustedIter ¶
type ExhaustedIter[T any] struct{}
ExhaustedIter implements `Exhausted`. See `Exhausted`'s documentation.
func Exhausted ¶
func Exhausted[T any]() *ExhaustedIter[T]
Exhausted instantiates an `ExhaustedIter` that will immediately be exhausted (`Next` will always return a `None` variant).
func (*ExhaustedIter[T]) Next ¶
func (iter *ExhaustedIter[T]) Next() option.Option[T]
Next implements the Iterator interface for `ExhaustedIter`.
type FilterIter ¶
type FilterIter[T any] struct { // contains filtered or unexported fields }
FilterIter implements `Filter`. See `Filter`'s documentation.
func Exclude ¶
func Exclude[T any](iter Iterator[T], fun func(T) bool) *FilterIter[T]
Exclude instantiates a `FilterIter` that selectively yields only results that cause the provided function to return `false`.
func Filter ¶
func Filter[T any](iter Iterator[T], fun func(T) bool) *FilterIter[T]
Filter instantiates a `FilterIter` that selectively yields only results that cause the provided function to return `true`.
func (*FilterIter[T]) Next ¶
func (iter *FilterIter[T]) Next() option.Option[T]
Next implements the Iterator interface for `Filter`.
type Iterator ¶
Iterator declares that each Iterator must implement a Next method. Successive calls to the next method shall return the next item in the Iterator, wrapped in an `Option.Some` variant.
Exhausted Iterators shall return a `None` variant of `Option` on every subsequent call.
type LiftIter ¶
type LiftIter[T any] struct { // contains filtered or unexported fields }
LiftIter implements `Lift`. See `Lift`'s documentation.
type LinesIter ¶
type LinesIter struct {
// contains filtered or unexported fields
}
LinesIter implements `Lines`. See `Lines`' documentation.
func Lines ¶
Lines instantiates a `LinesIter` that will yield each line from the provided `io.Reader`.
Be aware that since `Read` operations can fail, the result time of each item is `result.Result[[]byte]`. Errors will need to be handled as a failure is wrapped in an Ok variant. Multiple calls to `Next()` may simply repeat the same error and cause an infinite loop when collected.
type MapIter ¶
type MapIter[T, U any] struct { // contains filtered or unexported fields }
MapIter implements `Map`. See `Map`'s documentation.
func LinesString ¶
LinesString instantiates a `LinesIter` with results converted to a string via a MapIter. See `Lines` documentation for more information.
type TakeIter ¶
type TakeIter[T any] struct { // contains filtered or unexported fields }
TakeIter implements `Take`. See `Take`'s documentation.
func Take ¶
Take instantiates a `TakeIter` that will limit the number of items of its wrapped iterator to a maximum limit.
Example ¶
package main
import (
"fmt"
"github.com/BooleanCat/go-functional/iter"
)
func main() {
iter := iter.Take[int](iter.Count(), 2)
fmt.Println(iter.Next())
fmt.Println(iter.Next())
fmt.Println(iter.Next())
}
Output: Some(0) Some(1) None
type ZipIter ¶
type ZipIter[T, U any] struct { // contains filtered or unexported fields }
ZipIter implements `Zip`. See `Zip`'s documentation.