inty

package
Version: v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(v int) int

Abs returns the absolute value of v.

func Contains

func Contains(vs []int, v int) bool

Contains returns true if vs contains v.

func FromString

func FromString(s string) (int, error)

FromString parses s and returns a int.

func Int

func Int(v *int) int

Int dereferences and returns int. The int default value is returned if v is nil.

func IntOrDefault

func IntOrDefault(v *int, defaultVal int) *int

IntOrDefault returns int if it is not nil, and a pointer to defaultVal otherwise.

func Max

func Max(v int, vs ...int) int

Max returns the maximum value from v and vs.

func Min

func Min(v int, vs ...int) int

Min returns the minimum value from v and vs.

func Pointer

func Pointer(v int) *int

Pointer returns a pointer to the given int.

func Random

func Random() int

Random returns a non-negative pseudo-random number of type int

func RandomN

func RandomN(n int) int

RandomN returns a non-negative pseudo-random number in [0,n) of type int. It panics if n <= 0.

func Sort

func Sort(vs []int) []int

Sort sorts data in place. Not guaranteed to be stable.

func Unique

func Unique(vs []int) []int

Unique returns a new list containing unique ints from the given input

Types

type IntSlice

type IntSlice []int

func (IntSlice) Len

func (p IntSlice) Len() int

func (IntSlice) Less

func (p IntSlice) Less(i, j int) bool

func (IntSlice) Swap

func (p IntSlice) Swap(i, j int)

type Set

type Set map[int]struct{}

func MakeSet

func MakeSet(vs ...int) Set

MakeSet returns a lookup map for int

func ToSet

func ToSet(vs []int) Set

ToSet returns a lookup map for int.

func (Set) Contains

func (s Set) Contains(v int) bool

Contains returns true if Set contains v.

func (Set) Equal

func (s Set) Equal(s2 Set) bool

Equal checks whether all

func (Set) Intersect

func (s Set) Intersect(s2 Set) Set

Intersect returns the intersection of two Sets.

func (Set) Union

func (s Set) Union(s2 Set) Set

Union returns the union of two Sets.

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