proxy.golang.org : github.com/posener/compare
Package compare enables more readable and easier comparison tasks. This package provides easy value comparisons tasks (see list below) using a given three-way comparison function of the form `func(T, T) int`. (three-way comparison) https://en.wikipedia.org/wiki/Three-way_comparison. * [X] Comparable: get a comparable object for more readable code. * [x] Sort - sort a slice. * [x] Search - binary search for a value in a slice. * [x] MinMax - get minimal and maximal values of a slice. + [x] Select - get the K'th greatest value of a slice. * [x] IsSorted / IsStrictSorted - check if a slice is sorted. The Go standard library provides some comparison functions, like `strings.Compare`, `bytes.Compare`, `(time.Time).After`, and so forth. Using these functions is not that readable as using operators such as `==`, `>`, etc. This library provides some helper functions that makes Go code more readable. A simple example that shows how to use the compare library with different basic types. An example of comparing struct with multiple fields with different priorities.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/posener/compare
License: Apache-2.0
Latest release: about 5 years ago
First release: about 5 years ago
Namespace: github.com/posener
Last synced: 28 days ago