Documentation
¶
Overview ¶
Package aghalgo contains common generic algorithms and data structures.
TODO(a.garipov): Update to use type parameters in Go 1.18.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntIsBefore ¶
func IntIsBefore(a, b comparable) (less bool)
IntIsBefore is a helper sort function for UniquenessValidator.Validate. a and b must be of type int.
func StringIsBefore ¶
func StringIsBefore(a, b comparable) (less bool)
StringIsBefore is a helper sort function for UniquenessValidator.Validate. a and b must be of type string.
Types ¶
type UniquenessValidator ¶
type UniquenessValidator map[comparable]int64
UniquenessValidator allows validating uniqueness of comparable items.
func (UniquenessValidator) Add ¶
func (v UniquenessValidator) Add(elems ...comparable)
Add adds a value to the validator. v must not be nil.
func (UniquenessValidator) Merge ¶
func (v UniquenessValidator) Merge(other UniquenessValidator) (merged UniquenessValidator)
Merge returns a validator containing data from both v and other.
func (UniquenessValidator) Validate ¶
func (v UniquenessValidator) Validate(isBefore func(a, b comparable) (less bool)) (err error)
Validate returns an error enumerating all elements that aren't unique. isBefore is an optional sorting function to make the error message deterministic.