iter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package iter provides an interface for efficiently working with streams of data across different data structures and algorithms, enabling a more ergonomic coding.

Example
package main

import (
	"fmt"

	"github.com/theMagicalKarp/iter/pkg/iter"
)

func main() {
	items := iter.New("hello", "world", "!!!")

	for item, ok := items.Next(); ok; item, ok = items.Next() {
		fmt.Println(item)
	}
}
Output:

hello
world
!!!

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterable

type Iterable[T any] interface {
	// Next returns the next element in the collection and a boolean value indicating if the value was found.
	Next() (T, bool)
}

Iterable represents a generic iterable collection.

func New

func New[T any](items ...T) Iterable[T]

NewIter creates a new iterable from the given items. It takes a variadic parameter `items` of type `T` and returns an `Iterable` of type `T`. The `Iterable` allows iterating over the items using the `Next` method.

Jump to

Keyboard shortcuts

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