Documentation ¶
Overview ¶
Package lang provides extensions and utilities to builtin language features.
Index ¶
- func Compare[T constraints.Ordered](a, b T) int
- func Equals[T comparable](a, b T) bool
- func Equivalent[T comparable](a, b Iterator[T]) bool
- func EquivalentT[T any](a, b Iterator[T], eq EqualsFn[T]) bool
- func Sprint[T any](it Iterator[T]) string
- func ToList[T any](it Iterator[T]) []T
- type CompareFn
- type EqualsFn
- type Iterator
- type Optional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare[T constraints.Ordered](a, b T) int
func Equals ¶
func Equals[T comparable](a, b T) bool
func Equivalent ¶
func Equivalent[T comparable](a, b Iterator[T]) bool
Equivalent compares all elements.
func EquivalentT ¶
EquivalentT compares all elements using the given equality function.
Types ¶
type CompareFn ¶
CompareFn defines ordering for arbitrary types, returning -1 if a < b, 0 if a == b and 1 if a > b. This function is not a method to avoid a boxing penalty for every natively-ordered object in a data structure.
type EqualsFn ¶
EqualsFn defines equality for arbitrary types. This function is not a method to avoid a boxing penalty for every natively-ordered object in a data structure.
type Iterator ¶
Iterator allows a caller-controlled iteration over a set of elements. It is expected to be lazily-computed, such that the cost is proportional to the number of elements consumed.