item

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Overview

Package item provides helper types and constraints for Stream operator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[T Addable](a, b T) T

Add the two arguments using the plus + operator

func Equals

func Equals[T comparable](reference T) func(i T) bool

Equals returns a predicate that is true when the checked value is equal to the provided reference.

func GreaterThan

func GreaterThan[T constraints.Ordered](reference T) func(i T) bool

GreaterThan returns a predicate that is true when the checked value is larger than the provided reference.

func GreaterThanOrEq

func GreaterThanOrEq[T constraints.Ordered](reference T) func(i T) bool

GreaterThanOrEq returns a predicate that is true when the checked value is equal or larger than the provided reference.

func Increment

func Increment[T Number](a T) T

Increment the argument

func IsZero

func IsZero[T comparable](input T) bool

IsZero returns true if the input value corresponds to the zero value of its type: 0 for numeric values, empty string, false, nil pointer, etc...

func LessThan

func LessThan[T constraints.Ordered](reference T) func(i T) bool

LessThan returns a predicate that is true when the checked value is less than the provided reference.

func LessThanOrEq

func LessThanOrEq[T constraints.Ordered](reference T) func(i T) bool

LessThanOrEq returns a predicate that is true when the checked value is equal or less than the provided reference.

func Multiply

func Multiply[T Number](a, b T) T

Multiply the two arguments using the multiplication * operator

func Neg

func Neg[T Number](a T) T

Neg inverts the sign of the given numeric argument

func Not

func Not[T any](condition func(i T) bool) func(i T) bool

Not negates the boolean result of the input condition function

Types

type Addable

type Addable interface {
	constraints.Ordered | constraints.Complex
}

Number constraint any type that define the addition + operation, and their subtypes

type Number

type Number interface {
	constraints.Integer | constraints.Float | constraints.Complex
}

Number constraint: ints, uints, complexes, floats and all their subtypes

type Pair

type Pair[K comparable, V any] struct {
	Key K
	Val V
}

Pair of Key-Value made to manage maps and other key-value structures TODO: use "constraints.Map" when it is defined in the constraints package

Jump to

Keyboard shortcuts

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