list

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element = list.Element

type FilterFunc

type FilterFunc func(e *Element) bool

FilterFunc is a user provided function to filter elements on a list.

type List

type List struct {
	*list.List
}

List is an augmentation of a container/list that provides convenience functions.

func New

func New() *List

New returns a new List

func (*List) All

func (l *List) All(fn FilterFunc, opts ...Option) *List

All returns a new list containing all the matching elements given the FilterFunc fn.

func (*List) Discard

func (l *List) Discard(fn FilterFunc, opts ...Option) int

Discard removes all items matching the FilterFunc from the list.

func (*List) DiscardFirst

func (l *List) DiscardFirst(fn FilterFunc, opts ...Option) bool

Discard removes the first item matching the FilterFunc from the list.

func (*List) Each

func (l *List) Each(fn FilterFunc, opts ...Option)

Each iterate over a List executing fn on every item. Each will stop the iteration if fn returns false.

func (*List) First

func (l *List) First(fn FilterFunc, opts ...Option) *list.Element

First returns the first element in the list matching FilterFunc.

func (*List) String

func (l *List) String() string

String returns the string representation of the List It calls .String() on items if defined.

type Option added in v0.4.0

type Option int
const (
	Backward Option = 1 << iota
)

type Options added in v0.4.0

type Options []Option

func (Options) Backward added in v0.4.0

func (opts Options) Backward() bool

Jump to

Keyboard shortcuts

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