defcon

package
v0.0.0-...-1c0ff78 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package defcon means DEFault CONtainers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[E any](inp []E, f func(E) E) []E

func ApplyMap

func ApplyMap[K comparable, V any](inp map[K]V, f func(V) V) map[K]V

func Contains

func Contains[E comparable](inp []E, haystack E) bool

func ContainsFunc

func ContainsFunc[E1 any, E2 any](inp []E1, haystack E2, eq func(E1, E2) bool) bool

func Filter

func Filter[V any](inp []V, filter func(V) bool) []V

func MapHasKey

func MapHasKey[K comparable, V any](inp map[K]V, key K) bool

func RemoveInplaceUnordered

func RemoveInplaceUnordered[E comparable](inp []E, haystack E) []E

func Reverse

func Reverse[E any](inp []E) []E

func ShallowCloneList

func ShallowCloneList[M ~[]V, V any](inp M) M

func ShallowCloneMap

func ShallowCloneMap[M ~map[K]V, K comparable, V any](inp M) M

func Transform

func Transform[E1 any, E2 any](inp []E1, f func(E1) E2) []E2

func TransformMapToList

func TransformMapToList[K comparable, V any, E any](inp map[K]V, f func(V) E) []E

func Unique

func Unique[V any, K comparable](inp []V, keyfunc func(V) K) []V

func UniqueComparable

func UniqueComparable[V comparable](inp []V) []V

func UniqueComparableOrdered

func UniqueComparableOrdered[V comparable](inp []V) []V

Types

type ListGenerator

type ListGenerator[K any] func() (K, bool)

type ListIterator

type ListIterator[E any] interface {
	Map(func(E) E) ListIterator[E]
	MapIndex(func(int, E) E) ListIterator[E]
	Filter(func(E) bool) ListIterator[E]
	FilterIndex(func(int, E) bool) ListIterator[E]
	Sort(less func(E, E) bool) ListIterator[E]
	Unique(func(E) string) ListIterator[E]

	Skip(count int) ListIterator[E]
	Limit(count int) ListIterator[E]

	Count() int

	Apply(func(E)) int
	ApplyIndex(func(int, E))
	Finalize() []E
	Intermediate() ListIterator[E]
}

func ConvertIterators

func ConvertIterators[I any, O any](inp ListIterator[I], cb func(I) O) ListIterator[O]

func ConvertMapToListIterator

func ConvertMapToListIterator[IK comparable, IV, OV any](inp MapIterator[IK, IV], cb func(IK, IV) OV) ListIterator[OV]

func IteratorFromList

func IteratorFromList[E any](inp []E) ListIterator[E]

func IteratorFromListWithCallback

func IteratorFromListWithCallback[E any, I any](inp []E, cb func(E) I) ListIterator[I]

func IteratorFromMapKeys

func IteratorFromMapKeys[K comparable, V any](inp map[K]V) ListIterator[K]

func IteratorFromMapValues

func IteratorFromMapValues[K comparable, V any](inp map[K]V) ListIterator[V]

func ListIteratorFromGenerator

func ListIteratorFromGenerator[E any](generator func() (E, bool), count int) ListIterator[E]

func MergeIterators

func MergeIterators[V any](iters ...ListIterator[V]) ListIterator[V]

func NewListIterator

func NewListIterator[E any](gen ListGenerator[E], maxElements int) ListIterator[E]

type MapGenerator

type MapGenerator[K comparable, V any] func() (K, V, bool)

type MapIterator

type MapIterator[K comparable, V any] interface {
	MapV(func(K, V) V) MapIterator[K, V]
	MapKV(func(K, V) (K, V)) MapIterator[K, V]
	Filter(func(K, V) bool) MapIterator[K, V]
	Unique(func(K, V) string) MapIterator[K, V]

	MapVIndex(func(int, K, V) V) MapIterator[K, V]
	MapKVIndex(func(int, K, V) (K, V)) MapIterator[K, V]
	FilterIndex(func(int, K, V) bool) MapIterator[K, V]

	Apply(func(K, V))
	Finalize() map[K]V
	Intermediate(less func(K, K) bool) MapIterator[K, V]

	Skip(count int) MapIterator[K, V]
	Limit(count int) MapIterator[K, V]

	KeyIterator() ListIterator[K]
	ValueIterator() ListIterator[V]
}

func ConvertListToMapIterator

func ConvertListToMapIterator[OK comparable, IV, OV any](
	inp ListIterator[IV], cb func(IV) (OK, OV),
) MapIterator[OK, OV]

func ConvertMapIterators

func ConvertMapIterators[IK, OK comparable, IV, OV any](
	inp MapIterator[IK, IV], cb func(IK, IV) (OK, OV),
) MapIterator[OK, OV]

func IteratorFromMap

func IteratorFromMap[K comparable, V any](inp map[K]V, less func(K, K) bool) MapIterator[K, V]

func MapIteratorFromGenerator

func MapIteratorFromGenerator[K comparable, V any](generator func() (K, V, bool), count int) MapIterator[K, V]

func NewMapIterator

func NewMapIterator[K comparable, V any](gen MapGenerator[K, V], maxElements int) MapIterator[K, V]

type Tuple2

type Tuple2[T1 any, T2 any] struct {
	// contains filtered or unexported fields
}

func NewTuple2

func NewTuple2[T1 any, T2 any](first T1, second T2) Tuple2[T1, T2]

func (*Tuple2[T1, T2]) First

func (t *Tuple2[T1, T2]) First() T1

func (*Tuple2[T1, T2]) Second

func (t *Tuple2[T1, T2]) Second() T2

func (*Tuple2[T1, T2]) Values

func (t *Tuple2[T1, T2]) Values() (T1, T2)

type Tuple3

type Tuple3[T1 any, T2 any, T3 any] struct {
	// contains filtered or unexported fields
}

func NewTuple3

func NewTuple3[T1 any, T2 any, T3 any](first T1, second T2, third T3) Tuple3[T1, T2, T3]

func (*Tuple3[T1, T2, T3]) First

func (t *Tuple3[T1, T2, T3]) First() T1

func (*Tuple3[T1, T2, T3]) Second

func (t *Tuple3[T1, T2, T3]) Second() T2

func (*Tuple3[T1, T2, T3]) Third

func (t *Tuple3[T1, T2, T3]) Third() T3

func (*Tuple3[T1, T2, T3]) Values

func (t *Tuple3[T1, T2, T3]) Values() (T1, T2, T3)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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