Documentation
¶
Index ¶
- type C
- func (c *C) BufferSize(n int) *C
- func (c *C) Bytes(r io.Reader) (*Iter[[]byte], error)
- func (c *C) InitialCap(n int) *C
- func (c *C) Lines(r io.Reader) (*Iter[string], error)
- func (c *C) MaxCap(n int) *C
- func (c *C) MaxLineLength(n int) *C
- func (c *C) Runes(r io.Reader) (*Iter[rune], error)
- func (c *C) WithContext(ctx context.Context) *C
- type Iter
- func Chan[T any](c *C, ch <-chan T) (*Iter[T], error)
- func Keys[K comparable, V any](m map[K]V) (*Iter[K], error)
- func Must[T any](src iter.Seq[T]) *Iter[T]
- func New[T any](src iter.Seq[T], initialCap, maxCap int) (*Iter[T], error)
- func Pairs[K comparable, V any](m map[K]V) (*Iter[Pair[K, V]], error)
- func Slice[T any](s []T) (*Iter[T], error)
- func Tea(sources ...io.Reader) (*Iter[string], error)
- func Vals[K comparable, V any](m map[K]V) (*Iter[V], error)
- func Wrap[T any](src iter.Seq[T]) (*Iter[T], error)
- func (it *Iter[T]) Buffer() []T
- func (it *Iter[T]) BufferedLen() int
- func (it *Iter[T]) Cap() int
- func (it *Iter[T]) Current() (T, bool)
- func (it *Iter[T]) Dump(fs ...func(value T) T) ([]T, error)
- func (it *Iter[T]) Next() (T, bool)
- func (it *Iter[T]) Peek() (T, bool)
- func (it *Iter[T]) Position() int
- func (it *Iter[T]) Rewind()
- func (it *Iter[T]) Seek(n int) (T, bool)
- func (it *Iter[T]) SeekTo(pos int) (T, bool)
- func (it *Iter[T]) Seq() iter.Seq[T]
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type C ¶
type C struct {
// contains filtered or unexported fields
}
C provides a builder for advanced iterator configuration.
func Config ¶
func Config() *C
Config starts a configuration builder for customized iterator creation. Defaults: InitialCap=64, MaxCap=0 (unlimited), BufferSize=4KB, MaxLineLength=64KB.
func (*C) BufferSize ¶
BufferSize sets the buffer size for Bytes (default 4KB).
func (*C) Bytes ¶
Bytes creates an Iter from io.Reader (chunks) with configuration. Returns an error for nil readers or read errors (except io.EOF).
func (*C) InitialCap ¶
InitialCap sets the initial buffer capacity (default 64).
func (*C) Lines ¶
Lines creates an Iter from io.Reader (line by line) with configuration. Returns an error for nil readers or scanning errors.
func (*C) MaxLineLength ¶
MaxLineLength sets the maximum line length for Lines (default 64KB).
type Iter ¶
type Iter[T any] struct { // contains filtered or unexported fields }
Iter provides buffered iteration over any iter.Seq[T] with: - Peek ahead without consumption - Relative (Seek) and absolute (SeekTo) navigation - Rewind capabilities - Configurable buffer limits
func Chan ¶
Chan creates an Iter from a channel with configuration and context. Returns an error for nil channels or context cancellation.
func Keys ¶
func Keys[K comparable, V any](m map[K]V) (*Iter[K], error)
Keys creates an Iter from map keys. Order is random (Go map iteration order). Returns an error for nil maps.
func New ¶
New creates an Iter with configurable buffer behavior. initialCap defaults to 64 if <= 0; maxCap of 0 means unlimited. Returns an error if the source sequence is nil.
func Pairs ¶
func Pairs[K comparable, V any](m map[K]V) (*Iter[Pair[K, V]], error)
Pairs creates an Iter from map entries. Order is random (Go map iteration order). Returns an error for nil maps.
func Slice ¶
Slice creates an Iter from []T. Preserves order and buffers all elements. Returns an error for nil slices.
func Tea ¶
Tea creates an Iter yielding lines from multiple io.Reader sources sequentially. Uses configuration from Config() with 64KB max line length. Returns an error for nil readers or if any reader is nil.
func Vals ¶
func Vals[K comparable, V any](m map[K]V) (*Iter[V], error)
Vals creates an Iter from map values. Order is random (Go map iteration order). Returns an error for nil maps.
func (*Iter[T]) Buffer ¶
func (it *Iter[T]) Buffer() []T
Buffer returns a copy of all buffered elements.
func (*Iter[T]) BufferedLen ¶
BufferedLen returns number of elements available for rewinding.
func (*Iter[T]) Dump ¶
Dump consumes the iterator and returns all elements as a slice. Similar to io.ReadAll, it includes buffered and remaining source elements.
func (*Iter[T]) Rewind ¶
func (it *Iter[T]) Rewind()
Rewind resets to initial state while preserving buffer.
func (*Iter[T]) Seek ¶
Seek moves n positions relative to current location, treating n as the number of elements to skip.