goalist

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average added in v0.1.7

func Average[T comparable, N constraints.Integer | constraints.Float](lst Goalist[T], averageFunc func(x T) N) *N

func Max added in v0.1.7

func Max[T comparable, N constraints.Ordered](lst Goalist[T], maxFunc func(x T) N) *N

func Min added in v0.1.7

func Min[T comparable, N constraints.Ordered](lst Goalist[T], minFunc func(x T) N) *N

func Sum added in v0.1.7

func Sum[T comparable, N constraints.Integer | constraints.Float | constraints.Complex](lst Goalist[T], sumFunc func(x T) N) *N

Types

type Goalist

type Goalist[T comparable] []T

func (*Goalist[T]) Add

func (l *Goalist[T]) Add(item T)

Add item to goalist Mutate the goalist

func (*Goalist[T]) AddRange

func (l *Goalist[T]) AddRange(lst Goalist[T])

Add goalist to goalist Mutate the goalist

func (Goalist[T]) All

func (l Goalist[T]) All(predicate func(x T) bool) bool

Return true if all values meet the predicate

func (Goalist[T]) Any

func (l Goalist[T]) Any(predicate func(x T) bool) bool

Return true if all values meet the predicate

func (*Goalist[T]) Clear

func (l *Goalist[T]) Clear()

Clear the goalist Mutates to goalist

func (Goalist[T]) Contains

func (l Goalist[T]) Contains(item T) bool

Returns true if goalist contains the item else return false

func (Goalist[T]) Count

func (l Goalist[T]) Count(predicate func(x T) bool) int

Get count of items that meet the predicate

func (Goalist[T]) Distinct

func (l Goalist[T]) Distinct() Goalist[T]

Remove duplicite items from goalist

func (Goalist[T]) Except

func (l Goalist[T]) Except(exceptList Goalist[T]) Goalist[T]

Remove items from actual Goalist that are in parameter of method

func (Goalist[T]) First

func (l Goalist[T]) First(predicate func(x T) bool) *T

Returns first item that meet the predicate

func (Goalist[T]) ForEach

func (l Goalist[T]) ForEach(function func(x T))

Iterate over the goalist and call the function from parameter on each one

func (Goalist[T]) GetEnumerator

func (l Goalist[T]) GetEnumerator() func() *T

Returns enumerable

func (Goalist[T]) GoForEach added in v0.1.6

func (l Goalist[T]) GoForEach(function func(x T))

Iterate over the goalist and call the function from parameter on each one

func (Goalist[T]) IndexOf

func (l Goalist[T]) IndexOf(value T) *int

Returns index of first item If the item is not in the goalist, then returns nil

func (*Goalist[T]) Insert

func (l *Goalist[T]) Insert(index int, value T)

Insert value to certain index

func (Goalist[T]) Intersect

func (l Goalist[T]) Intersect(intersectList Goalist[T]) Goalist[T]

Return items that are in both actual Goalist and Goalist from parameter

func (*Goalist[T]) Order

func (l *Goalist[T]) Order(predicate func(a, b T) int)

Order golist Return values of predicate 1, 0, -1 > 0 sort a after b < osort a before b 0 keep original order of a and b

func (*Goalist[T]) Remove

func (l *Goalist[T]) Remove(predicate func(x T) bool)

Remove element according to predicate numbers := goalist.Goalist[int]{1, 2 } numbers.Remove(func(x int) bool { return x == 1 }) will mutate list and remove 1

func (*Goalist[T]) RemoveAt

func (l *Goalist[T]) RemoveAt(index int)

Remove item from goalist on certain index

func (*Goalist[T]) Reverse

func (l *Goalist[T]) Reverse()

Reverse list reversing goalist.Goalist[int]{1, 2, 3, 4, 5} will result to goalist.Goalist[int]{5, 4, 3, 2, 1}

func (Goalist[T]) SkipWhile

func (l Goalist[T]) SkipWhile(predicate func(x T) bool) Goalist[T]

Returns items that are after the predicate is met

func (Goalist[T]) TakeWhile

func (l Goalist[T]) TakeWhile(predicate func(x T) bool) Goalist[T]

Returns items that are before the predicate is met

func (Goalist[T]) Union

func (l Goalist[T]) Union(unionList Goalist[T]) Goalist[T]

Returs union of both actual Goalist and Goalist from parameter

func (Goalist[T]) Where

func (l Goalist[T]) Where(predicate func(x T) bool) Goalist[T]

Returns items that met the predicate

Jump to

Keyboard shortcuts

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