value

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package value defines helper functions to compare numeric and other value types as either ordered or unordered. It also contains helpers to perform set operations on collections, and find sub-sequences in sequences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsFloat

func AsFloat(value interface{}) (float64, bool)

AsFloat return the value as a flaot64 if possible

func AsInt

func AsInt(value interface{}) (int64, bool)

AsInt return the value as an int64 if possible

func AsUInt

func AsUInt(value interface{}) (uint64, bool)

AsUInt return the value as an uint64 if possible

func CompareOrdered

func CompareOrdered(lhs, rhs interface{}) (int, error)

CompareOrdered returns the result of the comparison of two values of compatible type that can be ordered, including ints, floats, strings, byte slices, and slices of comparable orderable values. Values of different type or values of the same type that cannot be ordered return an error.

func CompareUnordered

func CompareUnordered(lhs, rhs interface{}) (bool, error)

CompareUnordered returns the result of the equality comparison of two values of compatible type, including ints, floats, strings and slices of comparable values. Other values are compared with reflect.DeepEqual(). Values of different tyype that cannot be compared return an error.

func FormatSetValues added in v0.5.0

func FormatSetValues(s Set) string

func IndexOfSubsequence added in v0.5.0

func IndexOfSubsequence(seq, sub reflect.Value) int

func IsSequenceType added in v0.5.0

func IsSequenceType(v reflect.Value) bool

func MaxAbsoluteDifference

func MaxAbsoluteDifference(lhs, rhs interface{}) (float64, error)

MaxAbsoluteDifference returns the maximum absolute difference of all the components. Both values must have the same shape and must be composed of values convertible to float64 for comparison

func PreCheckSubsequence added in v0.5.0

func PreCheckSubsequence(v1, v2 reflect.Value) error

Types

type Set added in v0.5.0

type Set map[interface{}]struct{}

func ReflectSet added in v0.5.0

func ReflectSet(value interface{}) (s Set, err error)

func (Set) Intersect added in v0.5.0

func (lhs Set) Intersect(rhs Set) (r Set)

func (Set) Minus added in v0.5.0

func (lhs Set) Minus(rhs Set) (r Set)

func (Set) Union added in v0.5.0

func (lhs Set) Union(rhs Set) (r Set)

Jump to

Keyboard shortcuts

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