int32s

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BitSize is the size in bits of this type.
	BitSize = 32
)

Variables

This section is empty.

Functions

func Parse

func Parse(v string) (int32, error)

Parse parses a string as base 10 int32.

func Ptr

func Ptr(v int32) *int32

Ptr returns a pointer to the value.

func PtrDefToNil

func PtrDefToNil(v int32, def int32) *int32

PtrDefToNil returns a pointer to the value, or nil if "def".

func PtrZeroToNil

func PtrZeroToNil(v int32) *int32

PtrZeroToNil returns a pointer to the value, or nil if 0.

func Val

func Val(v *int32) int32

Val returns the pointer value, defaulting to zero if nil.

func ValDef

func ValDef(v *int32, def int32) int32

ValDef returns the pointer value, defaulting to "def" if nil.

Types

type Map

type Map map[int32]struct{}

Map is a map of values.

func (Map) Clone

func (m Map) Clone() Map

Clone the Map.

func (Map) Filter

func (m Map) Filter(p PredicateFunc) Map

Filter the Map to a copy using the given PredicateFunc (if p(v) = true, the value is copied, otherwise skipped).

func (Map) ForEach

func (m Map) ForEach(r ReceiveFunc)

ForEach invokes ReceiveFunc for each key in the Map.

func (Map) Map

func (m Map) Map(t TransformFunc) Map

Map the Map to a copy using the given TransformFunc.

func (Map) ToSlice

func (m Map) ToSlice() Slice

ToSlice converts the Map to a Slice.

type PredicateFunc

type PredicateFunc func(int32) bool

PredicateFunc describes a function that evaluates values of type int32.

func And

func And(ps ...PredicateFunc) PredicateFunc

And performs a lazy logical AND using the given PredicateFunc(s). Always returns true if len(ps) = 0.

func Eq

func Eq(eq int32) PredicateFunc

Eq returns a PredicateFunc that evaluates v == eq.

func GT

func GT(gt int32) PredicateFunc

GT returns a PredicateFunc that evaluates v > gt.

func GTE

func GTE(gte int32) PredicateFunc

GTE returns a PredicateFunc that evaluates v > gte.

func LT

func LT(lt int32) PredicateFunc

LT returns a PredicateFunc that evaluates v < lt.

func LTE

func LTE(lte int32) PredicateFunc

LTE returns a PredicateFunc that evaluates v <= lte.

func Not

Not negates the PredicateFunc.

func Or

func Or(ps ...PredicateFunc) PredicateFunc

Or performs a lazy logical OR using the given PredicateFunc(s). Always returns false if len(ps) = 0.

type ReceiveFunc

type ReceiveFunc func(int32)

ReceiveFunc describes a function that receives values of type int32.

type Slice

type Slice []int32

Slice is a slice of values.

func (Slice) Apply

func (s Slice) Apply(t TransformFunc)

Apply the given TransformFunc in place.

func (Slice) Clone

func (s Slice) Clone() Slice

Clone the Slice.

func (Slice) Filter

func (s Slice) Filter(p PredicateFunc) Slice

Filter the Slice to a copy using the given PredicateFunc (if p(v) = true, the value is copied, otherwise skipped).

func (Slice) ForEach

func (s Slice) ForEach(r ReceiveFunc)

ForEach invokes ReceiveFunc for each value in the Slice.

func (Slice) IsSorted

func (s Slice) IsSorted() bool

IsSorted returns true if the slice is sorted.

func (Slice) Len

func (s Slice) Len() int

Len implements the sort.Interface interface.

func (Slice) Less

func (s Slice) Less(i, j int) bool

Less implements the sort.Interface interface.

func (Slice) Map

func (s Slice) Map(t TransformFunc) Slice

Map the Slice to a copy using the given TransformFunc.

func (Slice) SafeGet

func (s Slice) SafeGet(i int) int32

SafeGet returns "s[i]" if possible, 0 otherwise.

func (Slice) SafeGetDef

func (s Slice) SafeGetDef(i int, def int32) int32

SafeGetDef returns "s[i]" if possible, "def" otherwise.

func (Slice) SafeGetPtr

func (s Slice) SafeGetPtr(i int) *int32

SafeGetPtr returns a pointer to the value of "s[i]" if possible, an nil otherwise.

func (Slice) Sort

func (s Slice) Sort()

Sort the slice.

func (Slice) Swap

func (s Slice) Swap(i, j int)

Swap implements the sort.Interface interface.

func (Slice) ToInterfaces

func (s Slice) ToInterfaces() []interface{}

ToInterfaces copies all elements of the Slice to a []interface{}.

func (Slice) ToMap

func (s Slice) ToMap() Map

ToMap converts the Slice to a Map.

type TransformFunc

type TransformFunc func(int32) int32

TransformFunc describes a function that transforms values of type int32.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL