slice

package
v0.0.0-...-234771b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package slice implements helpers for slice operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain[T any] struct {
	// contains filtered or unexported fields
}

Chain is a series of slices of type T that have been "chained" together, i.e. they can be iterated on as one slice

func NewChain

func NewChain[T any](slices ...[]T) Chain[T]

NewChain returns a new chain composed of the passed in slices

func (Chain[T]) Get

func (c Chain[T]) Get(i int) T

Get returns a slice item at index `i`, where 0 <= `i` < c.Len()

func (Chain[T]) Iterate

func (c Chain[T]) Iterate(f func(i int, v *T))

Iterate iterates over the chained slices in order calling function `f` on each item

func (Chain[T]) Len

func (c Chain[T]) Len() int

Len returns the sum of the lengths of the chained slices

Jump to

Keyboard shortcuts

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