Documentation ¶
Index ¶
- func Abs[T constraints.Signed](x T) T
- func Clamp[T constraints.Ordered](x, floor, ceil T) T
- func ForkChannel[T any](in <-chan T) (out1, out2 <-chan T)
- func Max[T constraints.Ordered](a, b T) T
- func Min[T constraints.Ordered](a, b T) T
- func Pow[T constraints.Signed](x, y T) T
- func ProbeChannel[T any](in <-chan T, f func(v T)) (out <-chan T)
- func SafeAddUint16(a, b uint16) uint16
- func SafeAddUint8(a, b uint8) uint8
- func SafeSubUint16(a, b uint16) uint16
- func SafeSubUint8(a, b uint8) uint8
- func Sign[T constraints.Signed](x T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clamp ¶
func Clamp[T constraints.Ordered](x, floor, ceil T) T
Clamp returns x clamped to the range [floor, ceil].
func ForkChannel ¶
func ForkChannel[T any](in <-chan T) (out1, out2 <-chan T)
ForkChannel duplicates the input channel into two output channels.
func ProbeChannel ¶
func ProbeChannel[T any](in <-chan T, f func(v T)) (out <-chan T)
ProbeChannel duplicates the input channel into two output channels, applying a function to one of them and returning the other. Use this to e.g., log the data going through a channel.
func SafeAddUint16 ¶
SafeAddInt16 adds a and b, returning math.MaxInt16 if the result would be greater than math.MaxInt16.
func SafeAddUint8 ¶
SafeAddInt8 adds a and b, returning math.MaxInt8 if the result would be greater than math.MaxInt8.
func SafeSubUint16 ¶
SafeSubInt16 subtracts b from a, returning 0 if the result would be less than 0.
func SafeSubUint8 ¶
SafeSubInt8 subtracts b from a, returning 0 if the result would be less than 0.
func Sign ¶
func Sign[T constraints.Signed](x T) T
Sign returns -1 if x < 0, 1 if x > 0, and 0 if x == 0.
Types ¶
This section is empty.