mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-29 08:42:14 +00:00
21 lines
526 B
Go
21 lines
526 B
Go
|
package common
|
||
|
|
||
|
import (
|
||
|
"sort"
|
||
|
)
|
||
|
|
||
|
// Sort for []uint64
|
||
|
|
||
|
type UInt64Slice []uint64
|
||
|
|
||
|
func (p UInt64Slice) Len() int { return len(p) }
|
||
|
func (p UInt64Slice) Less(i, j int) bool { return p[i] < p[j] }
|
||
|
func (p UInt64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||
|
func (p UInt64Slice) Sort() { sort.Sort(p) }
|
||
|
|
||
|
func SearchUInt64s(a []uint64, x uint64) int {
|
||
|
return sort.Search(len(a), func(i int) bool { return a[i] >= x })
|
||
|
}
|
||
|
|
||
|
func (p UInt64Slice) Search(x uint64) int { return SearchUInt64s(p, x) }
|