Documentation
¶
Index ¶
- func BetweenExclusive[T constraints.Ordered](min, max, val T) bool
- func BetweenInclusive[T constraints.Ordered](min, max, val T) bool
- func Diff[T Number](a, b T) T
- func Div[T Number](a, b T) T
- func Max[T constraints.Ordered](a, b T) T
- func MaxValue[T constraints.Ordered](a []T) T
- func Min[T constraints.Ordered](a, b T) T
- func MinValue[T constraints.Ordered](a []T) T
- func Mult[T Number](a, b T) T
- func Sub[T Number](a, b T) T
- func Sum[T Number](a, b T) T
- type MinMaxValue
- func (p *MinMaxValue[T]) Cur() T
- func (p *MinMaxValue[T]) Format(format string, a ...any) string
- func (p *MinMaxValue[T]) GobDecode(v []byte) error
- func (p *MinMaxValue[T]) GobEncode() ([]byte, error)
- func (p *MinMaxValue[T]) Max() T
- func (p *MinMaxValue[T]) Min() T
- func (p *MinMaxValue[T]) ReadFrom(r io.Reader) error
- func (p *MinMaxValue[T]) Reset()
- func (p *MinMaxValue[T]) ToMap() map[string]interface{}
- func (p *MinMaxValue[T]) Update(v T)
- func (p *MinMaxValue[T]) WriteTo(w io.Writer) error
- type Number
- type Set
- func (p *Set[T]) Clear()
- func (p *Set[T]) Difference(set *Set[T]) *Set[T]
- func (p *Set[T]) Do(f func(T))
- func (p *Set[T]) ForEach(f func(T) error) error
- func (p *Set[T]) Has(element T) bool
- func (p *Set[T]) HasItems() bool
- func (p *Set[T]) Insert(elements ...T)
- func (p *Set[T]) Intersection(set *Set[T]) *Set[T]
- func (p *Set[T]) Len() int
- func (p *Set[T]) ProperSubsetOf(set *Set[T]) bool
- func (p *Set[T]) Remove(elements ...T)
- func (p *Set[T]) RemoveSet(set *Set[T])
- func (p *Set[T]) SubsetOf(set *Set[T]) bool
- func (p *Set[T]) ToSlice() *Slice[T]
- func (p *Set[T]) Union(set *Set[T]) *Set[T]
- func (p *Set[T]) Values() []T
- type Slice
- func (p *Slice[T]) Append(v T) *Slice[T]
- func (p *Slice[T]) Clone() *Slice[T]
- func (p *Slice[T]) Enumerate(fn func(item T) error) error
- func (p *Slice[T]) Exists(fn func(val T) bool) bool
- func (p *Slice[T]) First() T
- func (p *Slice[T]) GetAt(idx int) T
- func (p *Slice[T]) InsertAt(idx int, v T) *Slice[T]
- func (p *Slice[T]) Last() T
- func (p *Slice[T]) Len() int
- func (p *Slice[T]) Map(fn func(T) T) *Slice[T]
- func (p *Slice[T]) Prepend(v T) *Slice[T]
- func (p *Slice[T]) Reduce(initializer T, f func(T, T) T) T
- func (p *Slice[T]) Remove(idx int) *Slice[T]
- func (p *Slice[T]) Reset()
- func (p *Slice[T]) Select(fn func(T) bool) *Slice[T]
- func (p *Slice[T]) Sort(fn func(x, y T) int) *Slice[T]
- func (p *Slice[T]) Take(nCount int) *Slice[T]
- func (p *Slice[T]) Values() []T
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BetweenExclusive ¶
func BetweenExclusive[T constraints.Ordered](min, max, val T) bool
Between checks if val is between min and max, exclusive.
func BetweenInclusive ¶
func BetweenInclusive[T constraints.Ordered](min, max, val T) bool
Between checks if val is between min and max, inclusive.
func Max ¶
func Max[T constraints.Ordered](a, b T) T
Max returns the larger of a and b. If a == b, a is returned.
This function is intended to be used with types that support the constraints.Ordered type constraint, such as int, float64, and string.
func MaxValue ¶
func MaxValue[T constraints.Ordered](a []T) T
MaxValue returns the largest value in a slice. Assumes the slice is non-empty.
func Min ¶
func Min[T constraints.Ordered](a, b T) T
Min returns the smaller of a and b. If a == b, a is returned. This function is intended to be used with types that support the constraints.Ordered type constraint, such as int, float64, and string.
func MinValue ¶
func MinValue[T constraints.Ordered](a []T) T
MinValue returns the smallest value in a slice. If the slice is empty, it returns the zero value of type 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]) 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]) 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)
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func (*Set[T]) Difference ¶
Find the difference between two sets
func (*Set[T]) ForEach ¶
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 ¶
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]) Intersection ¶
Find the intersection of two sets
func (*Set[T]) ProperSubsetOf ¶
Test whether or not p set is a proper subset of "set"
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }
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.