types

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 8 Imported by: 15

Documentation

Index

Constants

View Source
const (
	CmpLesser  = -1
	CmpEqual   = 0
	CmpGreater = 1
)

Variables

This section is empty.

Functions

func Abs

func Abs[T Rational](v T) T

func Add

func Add[T Rational](l, r T) T

func As

func As[F, T any](f F) T

func AsAny

func AsAny[T any](t T) any

func AsKey

func AsKey[K, V any](o any) K

func AsResultFn

func AsResultFn[T any](fn func() (T, error)) func() Result[T]

func BoolNum

func BoolNum[T Rational](b bool) T

func CanAssign

func CanAssign[F, T any]() bool

func CastRat

func CastRat[F, T Rational](f F) T

func Choose

func Choose[T any](b bool, t T, f T) T

func Clamp

func Clamp[T constraints.Ordered](v, lo, hi T) T

func CloneSlice

func CloneSlice[T any](s []T) []T

func CmpAs

func CmpAs[F, T any](impl CmpImpl[T]) func(l, r F) CmpResult

func Coalesce

func Coalesce[T comparable](vs ...T) T

func CoalesceR

func CoalesceR[T comparable](vs ...T) T

func Const

func Const[T any](v T) func() T

func DefaultHash

func DefaultHash() hash.Hash64

func Div

func Div[T Rational](l, r T) T

func Eq

func Eq[T comparable](l, r T) bool

func Ge

func Ge[T constraints.Ordered](l, r T) bool

func Gt

func Gt[T constraints.Ordered](l, r T) bool

func HashBytes

func HashBytes(s []byte) uintptr

func HashStr

func HashStr(s string) uintptr

func Identity

func Identity[T any]() func(T) T

func Is

func Is[I any](v any) bool

func KvMaker

func KvMaker[K, V any](fn func(v V) K) func(v V) Kv[K, V]

func Le

func Le[T constraints.Ordered](l, r T) bool

func Lt

func Lt[T constraints.Ordered](l, r T) bool

func Max

func Max[T constraints.Ordered](vs ...T) T

func Min

func Min[T constraints.Ordered](vs ...T) T

func Mod

func Mod[T constraints.Integer](l, r T) T

func Mul

func Mul[T Rational](l, r T) T

func Ne

func Ne[T comparable](l, r T) bool

func Pow2Ceil

func Pow2Ceil[T constraints.Integer](num T) T

func Prod

func Prod[T Rational](vs ...T) T

func PtrTo

func PtrTo[T any](v T) *T

func SetIfAbsent

func SetIfAbsent[T any](o *Optional[T], fn func() T) T

func Sub

func Sub[T Rational](l, r T) T

func Sum

func Sum[T Rational](vs ...T) T

func Zero

func Zero[T any]() T

Types

type AnyBox

type AnyBox interface {
	Get() any
}

type AnyIterable

type AnyIterable interface {
	AnyIterate() Iterator[any]
}

type AnyKv

type AnyKv interface {
	AnyK() any
	AnyV() any
}

type AnyMap

type AnyMap interface {
	Traversable[Kv[any, any]]

	Len() int
	Contains(k any) bool
	Get(k any) any
	TryGet(k any) (any, bool)
}

type AnyMapImpl

type AnyMapImpl[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func AnyMapOf

func AnyMapOf[K comparable, V any](m map[K]V) AnyMapImpl[K, V]

func (AnyMapImpl[K, V]) Contains

func (m AnyMapImpl[K, V]) Contains(k any) bool

func (AnyMapImpl[K, V]) ForEach

func (m AnyMapImpl[K, V]) ForEach(fn func(kv Kv[any, any]) bool) bool

func (AnyMapImpl[K, V]) Get

func (m AnyMapImpl[K, V]) Get(k any) any

func (AnyMapImpl[K, V]) Len

func (m AnyMapImpl[K, V]) Len() int

func (AnyMapImpl[K, V]) TryGet

func (m AnyMapImpl[K, V]) TryGet(k any) (any, bool)

type AnyOptional

type AnyOptional interface {
	Present() bool
	Interface() any
	ZeroInterface() any
	Type() reflect.Type
	Replace(any) AnyOptional
	// contains filtered or unexported methods
}

type AnySlice

type AnySlice interface {
	Iterable[any]
	Traversable[any]

	Len() int
	Get(int) any
}

type AnySliceImpl

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

func AnySliceOf

func AnySliceOf[T any](s []T) AnySliceImpl[T]

func (AnySliceImpl[T]) ForEach

func (s AnySliceImpl[T]) ForEach(fn func(v any) bool) bool

func (AnySliceImpl[T]) Get

func (s AnySliceImpl[T]) Get(i int) any

func (AnySliceImpl[T]) Iterate

func (s AnySliceImpl[T]) Iterate() Iterator[any]

func (AnySliceImpl[T]) Len

func (s AnySliceImpl[T]) Len() int

type AnySliceIterator

type AnySliceIterator struct {
	// contains filtered or unexported fields
}

func IterateAnySlice

func IterateAnySlice(s AnySlice) *AnySliceIterator

func (*AnySliceIterator) HasNext

func (i *AnySliceIterator) HasNext() bool

func (*AnySliceIterator) Iterate

func (i *AnySliceIterator) Iterate() Iterator[any]

func (*AnySliceIterator) Next

func (i *AnySliceIterator) Next() any

type BiFunc

type BiFunc[F, T any] struct {
	// contains filtered or unexported fields
}

func BiFuncOf

func BiFuncOf[F, T any](t func(F) T, f func(T) F) BiFunc[F, T]

func (BiFunc[F, T]) Call

func (b BiFunc[F, T]) Call(f F) T

func (BiFunc[F, T]) Flip

func (b BiFunc[F, T]) Flip() BiFunc[T, F]

func (BiFunc[F, T]) Unwrap

func (b BiFunc[F, T]) Unwrap() func(F) T

type Box

type Box[T any] interface {
	Get() T
}

type BoxImpl

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

func (BoxImpl[T]) Get

func (b BoxImpl[T]) Get() T

type Bytes

type Bytes struct {
	// contains filtered or unexported fields
}

func BytesOf

func BytesOf(s []byte) Bytes

func UnsafeBytesOf

func UnsafeBytesOf(s []byte) Bytes

func (Bytes) Compare

func (b Bytes) Compare(o Bytes) CmpResult

func (Bytes) Equals

func (b Bytes) Equals(o Bytes) bool

func (Bytes) ForEach

func (b Bytes) ForEach(fn func(v byte) bool) bool

func (Bytes) Get

func (b Bytes) Get(i int) byte

func (Bytes) Hash

func (b Bytes) Hash() uintptr

func (Bytes) Iterate

func (b Bytes) Iterate() Iterator[byte]

func (Bytes) Len

func (b Bytes) Len() int

func (Bytes) Slice

func (b Bytes) Slice() []byte

type CmpImpl

type CmpImpl[T any] func(l, r T) CmpResult

func DefaultCmpImpl

func DefaultCmpImpl[T any]() CmpImpl[T]

func KeyCmpImpl

func KeyCmpImpl[K, V any](cmp CmpImpl[K]) CmpImpl[Kv[K, V]]

func MethodCmpImpl

func MethodCmpImpl[T Comparer[T]]() CmpImpl[T]

type CmpResult

type CmpResult int8

func BoolCmp

func BoolCmp(l, r bool) CmpResult

func OrderedCmp

func OrderedCmp[T constraints.Ordered](l, r T) CmpResult

type Comparer

type Comparer[T any] interface {
	Compare(o T) CmpResult
}

type EqImpl

type EqImpl[T any] func(l, r T) bool

type Equaler

type Equaler[T any] interface {
	Equals(o T) bool
}

type ErrFn

type ErrFn = func() error

type HashEq

type HashEq[T any] interface {
	Hasher
	Equaler[T]
}

type HashEqImpl

type HashEqImpl[T any] struct {
	Hash HashImpl[T]
	Eq   EqImpl[T]
}

func BoolHashEq

func BoolHashEq() HashEqImpl[bool]

func DefaultHashEqImpl

func DefaultHashEqImpl[T any]() HashEqImpl[T]

func HashEqAs

func HashEqAs[F, T any](impl HashEqImpl[T]) HashEqImpl[F]

func HashEqOf

func HashEqOf[T any](hash HashImpl[T], eq EqImpl[T]) HashEqImpl[T]

func IntHashEq

func IntHashEq[T constraints.Integer]() HashEqImpl[T]

func MethodHashEqImpl

func MethodHashEqImpl[T HashEq[T]]() HashEqImpl[T]

func OptionalHashEq

func OptionalHashEq[T any](he HashEqImpl[T]) HashEqImpl[Optional[T]]

func StrHashEq

func StrHashEq() HashEqImpl[string]

type HashImpl

type HashImpl[T any] func(T) uintptr

type Hasher

type Hasher interface {
	Hash() uintptr
}

type Iterable

type Iterable[T any] interface {
	Iterate() Iterator[T]
}

type Iterator

type Iterator[T any] interface {
	Iterable[T]

	HasNext() bool
	Next() T
}

type IteratorExhaustedError

type IteratorExhaustedError struct{}

type Kv

type Kv[K, V any] struct {
	K K
	V V
}

func KvOf

func KvOf[K, V any](k K, v V) Kv[K, V]

func (Kv[K, V]) Any

func (kv Kv[K, V]) Any() Kv[any, any]

func (Kv[K, V]) AnyK

func (kv Kv[K, V]) AnyK() any

func (Kv[K, V]) AnyV

func (kv Kv[K, V]) AnyV() any

func (Kv[K, V]) GetK

func (kv Kv[K, V]) GetK() K

func (Kv[K, V]) GetV

func (kv Kv[K, V]) GetV() V

func (Kv[K, V]) Unpack

func (kv Kv[K, V]) Unpack() (K, V)

type LessImpl

type LessImpl[T any] func(l, r T) bool

func CmpLessImpl

func CmpLessImpl[T any](cmp CmpImpl[T]) LessImpl[T]

type Lesser

type Lesser[T any] interface {
	Less(o T) bool
}

type MutAnyBox

type MutAnyBox interface {
	AnyBox

	Set(v any)
}

type MutAnyMap

type MutAnyMap interface {
	AnyMap

	Put(k, v any)
	Delete(k any)
	Default(k, v any) bool
}

type MutAnyMapImpl

type MutAnyMapImpl[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func MutAnyMapOf

func MutAnyMapOf[K comparable, V any](m map[K]V) MutAnyMapImpl[K, V]

func (MutAnyMapImpl[K, V]) Contains

func (m MutAnyMapImpl[K, V]) Contains(k any) bool

func (MutAnyMapImpl[K, V]) Default

func (m MutAnyMapImpl[K, V]) Default(k, v any) bool

func (MutAnyMapImpl[K, V]) Delete

func (m MutAnyMapImpl[K, V]) Delete(k any)

func (MutAnyMapImpl[K, V]) ForEach

func (m MutAnyMapImpl[K, V]) ForEach(fn func(kv Kv[any, any]) bool) bool

func (MutAnyMapImpl[K, V]) Get

func (m MutAnyMapImpl[K, V]) Get(k any) any

func (MutAnyMapImpl[K, V]) Len

func (m MutAnyMapImpl[K, V]) Len() int

func (MutAnyMapImpl[K, V]) Put

func (m MutAnyMapImpl[K, V]) Put(k, v any)

func (MutAnyMapImpl[K, V]) TryGet

func (m MutAnyMapImpl[K, V]) TryGet(k any) (any, bool)

type MutAnySlice

type MutAnySlice interface {
	AnySlice

	Set(int, any)
}

type MutAnySliceImpl

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

func MutAnySliceOf

func MutAnySliceOf[T any](s []T) MutAnySliceImpl[T]

func (MutAnySliceImpl[T]) ForEach

func (s MutAnySliceImpl[T]) ForEach(fn func(v any) bool) bool

func (MutAnySliceImpl[T]) Get

func (s MutAnySliceImpl[T]) Get(i int) any

func (MutAnySliceImpl[T]) Iterate

func (s MutAnySliceImpl[T]) Iterate() Iterator[any]

func (MutAnySliceImpl[T]) Len

func (s MutAnySliceImpl[T]) Len() int

func (MutAnySliceImpl[T]) Set

func (s MutAnySliceImpl[T]) Set(i int, e any)

type MutBox

type MutBox[T any] interface {
	Box[T]

	Set(v T)
}

type MutBoxImpl

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

func (*MutBoxImpl[T]) Get

func (b *MutBoxImpl[T]) Get() T

func (*MutBoxImpl[T]) Set

func (b *MutBoxImpl[T]) Set(v T)

type NoCopy

type NoCopy struct{}

func (*NoCopy) Lock

func (*NoCopy) Lock()

Lock is a no-op used by -copylocks checker from `go vet`.

func (*NoCopy) Unlock

func (*NoCopy) Unlock()

type NoValueError

type NoValueError struct{}

func (NoValueError) Error

func (e NoValueError) Error() string

type Numeric

type Numeric interface {
	Rational | constraints.Complex
}

type Optional

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

func IfNotNil

func IfNotNil[T any](v any) Optional[T]

func Just

func Just[T any](v T) Optional[T]

func None

func None[T any]() Optional[T]

func (Optional[T]) FlatMap

func (o Optional[T]) FlatMap(f func(T) Optional[T]) Optional[T]

func (Optional[T]) ForEach

func (o Optional[T]) ForEach(fn func(v T) bool) bool

func (Optional[T]) IfAbsent

func (o Optional[T]) IfAbsent(fn func())

func (Optional[T]) IfPresent

func (o Optional[T]) IfPresent(fn func(v T))

func (Optional[T]) Interface

func (o Optional[T]) Interface() any

func (Optional[T]) Iterate

func (o Optional[T]) Iterate() Iterator[T]

func (Optional[T]) Map

func (o Optional[T]) Map(f func(T) T) Optional[T]

func (Optional[T]) MarshalJSON

func (o Optional[T]) MarshalJSON() ([]byte, error)

func (Optional[T]) Or

func (o Optional[T]) Or(d T) T

func (Optional[T]) OrFn

func (o Optional[T]) OrFn(f func() T) T

func (Optional[T]) OrZero

func (o Optional[T]) OrZero() T

func (Optional[T]) Present

func (o Optional[T]) Present() bool

func (Optional[T]) Replace

func (o Optional[T]) Replace(v any) AnyOptional

func (Optional[T]) Type

func (o Optional[T]) Type() reflect.Type

func (*Optional[T]) UnmarshalJSON

func (o *Optional[T]) UnmarshalJSON(b []byte) error

func (Optional[T]) Value

func (o Optional[T]) Value() T

func (Optional[T]) ZeroInterface

func (o Optional[T]) ZeroInterface() any

type Pair

type Pair[L, R any] struct {
	L L
	R R
}

func PairOf

func PairOf[L, R any](l L, r R) Pair[L, R]

func (Pair[L, R]) GetL

func (p Pair[L, R]) GetL() L

func (Pair[L, R]) GetR

func (p Pair[L, R]) GetR() R

func (Pair[L, R]) Unpack

func (p Pair[L, R]) Unpack() (L, R)

type Range

type Range[T Rational] struct {
	Start, Stop, Step T
}

func RangeOf

func RangeOf[T Rational](start, stop, step T) Range[T]

func RangeTo

func RangeTo[T Rational](stop T) Range[T]

func (Range[T]) AnyIterate

func (r Range[T]) AnyIterate() Iterator[any]

func (Range[T]) AsAnySlice

func (r Range[T]) AsAnySlice() AnySlice

func (Range[T]) AsSlice

func (r Range[T]) AsSlice() []T

func (Range[T]) CheckNormal

func (r Range[T]) CheckNormal(n T) Range[T]

func (Range[T]) ForEach

func (r Range[T]) ForEach(fn func(T) bool) bool

func (Range[T]) HasNext

func (r Range[T]) HasNext() bool

func (Range[T]) Iterate

func (r Range[T]) Iterate() Iterator[T]

func (Range[T]) Len

func (r Range[T]) Len() T

func (Range[T]) Next

func (r Range[T]) Next() (Range[T], bool)

func (Range[T]) Slice

func (r Range[T]) Slice() []T

func (Range[T]) StepOrOne

func (r Range[T]) StepOrOne() T

type RangeError

type RangeError[T Rational] struct {
	Range Range[T]
	Err   error
}

func (RangeError[T]) Error

func (e RangeError[T]) Error() string

func (RangeError[T]) Unwrap

func (e RangeError[T]) Unwrap() error

type Rational

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

type Result

type Result[T any] struct {
	Val T
	Err error
}

func AsResult

func AsResult[T any](v T, err error) Result[T]

func Err

func Err[T any](err error) Result[T]

func Ok

func Ok[T any](val T) Result[T]

func (Result[T]) GetErr

func (r Result[T]) GetErr() error

func (Result[T]) GetVal

func (r Result[T]) GetVal() T

func (Result[T]) Unpack

func (r Result[T]) Unpack() (T, error)

type Stringer

type Stringer interface {
	String() string
}

type Traversable

type Traversable[T any] interface {
	ForEach(fn func(v T) bool) bool
}

Jump to

Keyboard shortcuts

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