slice

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IZero    = Val{0}
	IUnbound = Val{-1}
)
View Source
var ErrZero = fmt.Errorf("expected non zero value")
View Source
var LenNonZero = &NonZero{}

Functions

func ConditionMet

func ConditionMet[T ComparableOrdered](eq EqualityKind, first, second T) (b bool)

func NonZeroLen

func NonZeroLen(l int)

func PanicOnInvalid

func PanicOnInvalid(ic IntCondition, l int)

Types

type ComparableOrdered

type ComparableOrdered interface {
	comparable
	constraints.Ordered
}

type EqualityCondition

type EqualityCondition[T ComparableOrdered] struct {
	// contains filtered or unexported fields
}

func NewCondition

func NewCondition[T ComparableOrdered](val T, ek EqualityKind) EqualityCondition[T]

func (EqualityCondition[T]) ConditionMet

func (eq EqualityCondition[T]) ConditionMet(val T) (err error)

type EqualityKind

type EqualityKind int
const (
	LargerThan EqualityKind = iota
	LessThan
	Equal
	NotEqual
	LessOrEqual
	LargerOrEuqal
)

func (EqualityKind) Repr

func (eq EqualityKind) Repr() (s string)

type ErrEqualityCondition

type ErrEqualityCondition[T any] struct {
	First, Second T
	Kind          EqualityKind
}

func (*ErrEqualityCondition[T]) Error

func (e *ErrEqualityCondition[T]) Error() (s string)

type ExpectedGot

type ExpectedGot[T ComparableOrdered] struct {
	Expected T

	Kind EqualityKind
	// contains filtered or unexported fields
}

func (ExpectedGot[T]) CheckCondition

func (eg ExpectedGot[T]) CheckCondition() error

func (*ExpectedGot[T]) Got

func (eg *ExpectedGot[T]) Got(got T) *ExpectedGot[T]

type ILowHigh

type ILowHigh int
const (
	ILow ILowHigh = iota
	IHigh
)

type IntCondition

type IntCondition interface {
	ConditionMet(l int) (err error)
}

type IterConfig

type IterConfig struct {
	Low  int
	High int
	Step int
}

type IterSetup

type IterSetup map[string]int

type LowHigh

type LowHigh [2]Val

func IFromSequence

func IFromSequence(ints ...int) (lh []LowHigh)

type NonZero

type NonZero struct{}

func (NonZero) ConditionMet

func (NonZero) ConditionMet(l int) (err error)

type Slice

type Slice struct {
	High int
	Low  int
}

func FirstN

func FirstN(n int) Slice

FirstN initializes an iterator that iterates over the first n elements.

func LastN

func LastN(n int) Slice

LastN initializes an iterator that iterates over the last n elements.

func NewSlice

func NewSlice() Slice

NewIter initializes a slice iterator with the High field set to unset the Step field set to 1 and Low field set to 0.

func (Slice) HighUnset

func (sl Slice) HighUnset() Slice

func (Slice) WithHigh

func (sl Slice) WithHigh(high int) Slice

func (Slice) WithLow

func (sl Slice) WithLow(low int) Slice

func (Slice) WithStep

func (sl Slice) WithStep(step int) WithStep

type Val

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

func NewVal

func NewVal(val int) (v Val)

func (Val) IsUnbound

func (v Val) IsUnbound() (b bool)

type WithStep

type WithStep struct {
	Step int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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