containers

package module
v0.0.0-...-44abe55 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 6 Imported by: 1

README

containers

golang generic containers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff[T Number](a, b T) T

func Div

func Div[T Number](a, b T) T

func Max

func Max[T constraints.Ordered](a, b T) T

func MaxValue

func MaxValue[T constraints.Ordered](a []T) T

func Min

func Min[T constraints.Ordered](a, b T) T

func MinValue

func MinValue[T constraints.Ordered](a []T) T

func Mult

func Mult[T Number](a, b T) T

func Sub

func Sub[T Number](a, b T) T

func Sum

func Sum[T Number](a, b T) T

Types

type MinMaxValue

type MinMaxValue[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func NewMinMaxValue

func NewMinMaxValue[T constraints.Ordered](v T) *MinMaxValue[T]

func (*MinMaxValue[T]) Cur

func (p *MinMaxValue[T]) Cur() T

func (*MinMaxValue[T]) Format

func (p *MinMaxValue[T]) Format(format string, a ...any) string

func (*MinMaxValue[T]) GobDecode

func (p *MinMaxValue[T]) GobDecode(v []byte) error

func (*MinMaxValue[T]) GobEncode

func (p *MinMaxValue[T]) GobEncode() ([]byte, error)

func (*MinMaxValue[T]) Max

func (p *MinMaxValue[T]) Max() T

func (*MinMaxValue[T]) Min

func (p *MinMaxValue[T]) Min() T

func (*MinMaxValue[T]) ReadFrom

func (p *MinMaxValue[T]) ReadFrom(r io.Reader) error

func (*MinMaxValue[T]) Reset

func (p *MinMaxValue[T]) Reset()

func (*MinMaxValue[T]) ToMap

func (p *MinMaxValue[T]) ToMap() map[string]interface{}

func (*MinMaxValue[T]) Update

func (p *MinMaxValue[T]) Update(v T)

func (*MinMaxValue[T]) WriteTo

func (p *MinMaxValue[T]) WriteTo(w io.Writer) error

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type Set

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

func NewSet

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

Create a new set

func (*Set[T]) Difference

func (p *Set[T]) Difference(set *Set[T]) *Set[T]

Find the difference between two sets

func (*Set[T]) Do

func (p *Set[T]) Do(f func(T))

Do calls f for each item in the set

func (*Set[T]) ForEach

func (p *Set[T]) ForEach(f func(T) error) error

ForEach calls the given function for each element in the set.

The function takes a parameter 'f' of type 'func(T) error'. It should receive an element of type 'T' and return an error if any.

It returns an error if the function 'f' returns an error during iteration. Otherwise, it returns nil.

func (*Set[T]) Has

func (p *Set[T]) Has(element T) bool

Has checks if the given element exists in the Set.

Parameters: - element: the element to check for existence in the Set.

Returns: - bool: true if the element exists in the Set, false otherwise.

func (*Set[T]) HasItems

func (p *Set[T]) HasItems() bool

Test if Set has any Items

func (*Set[T]) Insert

func (p *Set[T]) Insert(element T)

Add an element to the set

func (*Set[T]) Intersection

func (p *Set[T]) Intersection(set *Set[T]) *Set[T]

Find the intersection of two sets

func (*Set[T]) Len

func (p *Set[T]) Len() int

Return the number of items in the set

func (*Set[T]) ProperSubsetOf

func (p *Set[T]) ProperSubsetOf(set *Set[T]) bool

Test whether or not p set is a proper subset of "set"

func (*Set[T]) Remove

func (p *Set[T]) Remove(elements ...T)

Remove given elements from the set

func (*Set[T]) RemoveSet

func (p *Set[T]) RemoveSet(set *Set[T])

Remove a set from the set

func (*Set[T]) SubsetOf

func (p *Set[T]) SubsetOf(set *Set[T]) bool

Test whether or not this set is a subset of "set"

func (*Set[T]) ToSlice

func (p *Set[T]) ToSlice() *Slice[T]

Transforms Set to Slice

func (*Set[T]) Union

func (p *Set[T]) Union(set *Set[T]) *Set[T]

Find the union of two sets

func (*Set[T]) Values

func (p *Set[T]) Values() []T

Get the sets values

type Slice

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

func NewSlice

func NewSlice[T any](v ...T) *Slice[T]

func (*Slice[T]) Append

func (p *Slice[T]) Append(v T) *Slice[T]

func (*Slice[T]) Clone

func (p *Slice[T]) Clone() *Slice[T]

func (*Slice[T]) Enumerate

func (p *Slice[T]) Enumerate(fn func(item T) error) error

func (*Slice[T]) Exists

func (p *Slice[T]) Exists(fn func(val T) bool) bool

func (*Slice[T]) First

func (p *Slice[T]) First() T

func (*Slice[T]) GetAt

func (p *Slice[T]) GetAt(idx int) T

func (*Slice[T]) InsertAt

func (p *Slice[T]) InsertAt(idx int, v T) *Slice[T]

func (*Slice[T]) Last

func (p *Slice[T]) Last() T

func (*Slice[T]) Len

func (p *Slice[T]) Len() int

func (*Slice[T]) Map

func (p *Slice[T]) Map(fn func(T) T) *Slice[T]

Map turns a []Elem1 to a []Elem2 using a mapping function.

func (*Slice[T]) Prepend

func (p *Slice[T]) Prepend(v T) *Slice[T]

func (*Slice[T]) Reduce

func (p *Slice[T]) Reduce(initializer T, f func(T, T) T) T

Reduce reduces a []T to a single value of type T using a reduction function.

func (*Slice[T]) Remove

func (p *Slice[T]) Remove(idx int) *Slice[T]

func (*Slice[T]) Reset

func (p *Slice[T]) Reset()

func (*Slice[T]) Select

func (p *Slice[T]) Select(fn func(T) bool) *Slice[T]

func (*Slice[T]) Sort

func (p *Slice[T]) Sort(fn func(x, y T) int) *Slice[T]

func (*Slice[T]) Take

func (p *Slice[T]) Take(nCount int) *Slice[T]

Take takes the first n items of []Elem

func (*Slice[T]) Values

func (p *Slice[T]) Values() []T

type Tuple

type Tuple[T1 any, T2 any] struct {
	T1Val T1
	T2Val T2
}

func (*Tuple[T1, T2]) Get1

func (p *Tuple[T1, T2]) Get1() T1

func (*Tuple[T1, T2]) Get2

func (p *Tuple[T1, T2]) Get2() T2

func (*Tuple[T1, T2]) Set

func (p *Tuple[T1, T2]) Set(v1 T1, v2 T2)

Jump to

Keyboard shortcuts

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