collection

package
v0.0.0-...-cfe670f Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fold

func Fold[T, V any](t Traversable[T], initialValue V, op func(a V, b T) V) V

func Max

func Max[T constraints.Ordered](t *traversable[T]) T

func Min

func Min[T constraints.Ordered](t *traversable[T]) T

func Product

func Product[T number](t *traversable[T]) T

func Ptr

func Ptr[T any](t T) *T

func Sum

func Sum[T number](t *traversable[T]) T

Types

type KV

type KV[K comparable, V any] map[K]V

func EmptyKV

func EmptyKV[K comparable, V any]() KV[K, V]

func NewKV

func NewKV[K comparable, V any](elements ...Tuple2[K, V]) KV[K, V]

func (KV[K, V]) ForEach

func (l KV[K, V]) ForEach(action func(tuple Tuple2[K, V]))

type List

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

func EmptyList

func EmptyList[T any]() *List[T]

func NewList

func NewList[T any](elements ...T) *List[T]

func (*List[T]) Add

func (l *List[T]) Add(elements ...T) *List[T]

func (*List) Count

func (t *List) Count(filter func(elem T) bool) int

func (*List) Exists

func (t *List) Exists(filter func(elem T) bool) bool

func (*List) Find

func (t *List) Find(filter func(elem T) bool) *Option[T]

func (*List) ForAll

func (t *List) ForAll(filter func(elem T) bool, transform func(elem T) T) *List[T]

func (*List[T]) ForEach

func (l *List[T]) ForEach(action func(T))

func (*List) GetOrElse

func (t *List) GetOrElse(altValue T) T

func (*List) Head

func (t *List) Head() (T, bool)

func (*List) HeadOption

func (t *List) HeadOption() *Option[T]

func (*List) IsDefined

func (t *List) IsDefined() bool

func (*List) IsEmpty

func (t *List) IsEmpty() bool

func (*List) Last

func (t *List) Last() (T, bool)

func (*List) LastOption

func (t *List) LastOption() *Option[T]

func (*List) NonEmpty

func (t *List) NonEmpty() bool

func (*List) Reduce

func (t *List) Reduce(op func(a, b T) T) T

func (*List) Select

func (t *List) Select(filter func(elem T) bool) *List[T]

func (*List) ToList

func (t *List) ToList() *List[T]

type Option

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

func NewOption

func NewOption[T any](value *T) *Option[T]

func None

func None[T any]() *Option[T]

func Some

func Some[T any](value T) *Option[T]

func (*Option) Count

func (t *Option) Count(filter func(elem T) bool) int

func (*Option) Exists

func (t *Option) Exists(filter func(elem T) bool) bool

func (*Option) Find

func (t *Option) Find(filter func(elem T) bool) *Option[T]

func (*Option) ForAll

func (t *Option) ForAll(filter func(elem T) bool, transform func(elem T) T) *List[T]

func (*Option[T]) ForEach

func (o *Option[T]) ForEach(action func(T))

func (*Option[T]) GetOrElse

func (o *Option[T]) GetOrElse(altValue T) T

func (*Option) Head

func (t *Option) Head() (T, bool)

func (*Option) HeadOption

func (t *Option) HeadOption() *Option[T]

func (*Option) IsDefined

func (t *Option) IsDefined() bool

func (*Option) IsEmpty

func (t *Option) IsEmpty() bool

func (*Option) Last

func (t *Option) Last() (T, bool)

func (*Option) LastOption

func (t *Option) LastOption() *Option[T]

func (*Option) NonEmpty

func (t *Option) NonEmpty() bool

func (*Option) Reduce

func (t *Option) Reduce(op func(a, b T) T) T

func (*Option) Select

func (t *Option) Select(filter func(elem T) bool) *List[T]

func (*Option) ToList

func (t *Option) ToList() *List[T]

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func EmptySet

func EmptySet[T comparable]() *Set[T]

func NewSet

func NewSet[T comparable](elements ...T) *Set[T]

func ToSet

func ToSet[T comparable](t *traversable[T]) *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(elements ...T) *Set[T]

func (*Set) Count

func (t *Set) Count(filter func(elem T) bool) int

func (*Set) Exists

func (t *Set) Exists(filter func(elem T) bool) bool

func (*Set) Find

func (t *Set) Find(filter func(elem T) bool) *Option[T]

func (*Set) ForAll

func (t *Set) ForAll(filter func(elem T) bool, transform func(elem T) T) *List[T]

func (Set[T]) ForEach

func (s Set[T]) ForEach(action func(T))

func (*Set) GetOrElse

func (t *Set) GetOrElse(altValue T) T

func (*Set) Head

func (t *Set) Head() (T, bool)

func (*Set) HeadOption

func (t *Set) HeadOption() *Option[T]

func (*Set) IsDefined

func (t *Set) IsDefined() bool

func (*Set) IsEmpty

func (t *Set) IsEmpty() bool

func (*Set) Last

func (t *Set) Last() (T, bool)

func (*Set) LastOption

func (t *Set) LastOption() *Option[T]

func (*Set) NonEmpty

func (t *Set) NonEmpty() bool

func (*Set) Reduce

func (t *Set) Reduce(op func(a, b T) T) T

func (*Set) Select

func (t *Set) Select(filter func(elem T) bool) *List[T]

func (*Set) ToList

func (t *Set) ToList() *List[T]

type Traversable

type Traversable[T any] interface {
	Head() (T, bool)
	HeadOption() *Option[T]
	GetOrElse(altValue T) T
	Last() (T, bool)
	LastOption() *Option[T]
	Find(filter func(elem T) bool) *Option[T]
	Exists(filter func(elem T) bool) bool
	Count(filter func(elem T) bool) int
	Select(filter func(elem T) bool) *List[T]
	ForAll(filter func(elem T) bool, transform func(elem T) T) *List[T]
	IsEmpty() bool
	NonEmpty() bool
	IsDefined() bool
	Reduce(op func(a, b T) T) T
	ToList() *List[T]
	// contains filtered or unexported methods
}

func Map

func Map[T, V any](t Traversable[T], transform func(T) V) Traversable[V]

type Tuple1

type Tuple1[T1 any] struct {
	Field1 T1
}

type Tuple2

type Tuple2[T1, T2 any] struct {
	Field1 T1
	Field2 T2
}

type Tuple3

type Tuple3[T1, T2, T3 any] struct {
	Field1 T1
	Field2 T2
	Field3 T3
}

type Tuple4

type Tuple4[T1, T2, T3, T4 any] struct {
	Field1 T1
	Field2 T2
	Field3 T3
	Field4 T4
}

Jump to

Keyboard shortcuts

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