extra

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Buffer

func Buffer[T any](s sequence.Sequence[T]) sequence.Sequence[T]

Buffer is an alternative to the Materialize method in that it keeps a cached copy of data from an underlying sequence, both for faster access and to support re-using a volatile sequence.

Unlike Materialize a buffered sequence fills it's storage as it delivers values to a client, so there is no wait when calling Buffer before using the new sequence, and an unused Buffer sequence takes up no additional memory aside from the generator itself. It's slightly slower as locks are needed to ensure multiple readers play well with the cache, as some may be updating the cache at the same time. This is not true of Materialize where every access after it's built is read-only, and can easily be parallelized.

func Lines

func Lines(r io.Reader) sequence.Sequence[string]

Lines returns a sequence that produces one at a time, lines of text from the provided reader. Errors while reading will interupt processing.

This version is Volatile, meaning that you can only iterate over the input a single time, as it can't "go back" and return old lines, since none are stored.

If you need to use the lines multiple times, consider calling Materialize on the returned sequence, or wrap it with [process.Buffer].

Types

This section is empty.

Jump to

Keyboard shortcuts

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