mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 14:34:17 +00:00
Added README docs for account/binary and renamed UInt -> Uint etc.
This commit is contained in:
+7
-7
@@ -6,15 +6,15 @@ import (
|
||||
|
||||
// Sort for []uint64
|
||||
|
||||
type UInt64Slice []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 (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 {
|
||||
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) }
|
||||
func (p Uint64Slice) Search(x uint64) int { return SearchUint64s(p, x) }
|
||||
|
||||
+8
-8
@@ -46,24 +46,24 @@ MAIN_LOOP:
|
||||
return string(chars)
|
||||
}
|
||||
|
||||
func RandUInt16() uint16 {
|
||||
func RandUint16() uint16 {
|
||||
return uint16(rand.Uint32() & (1<<16 - 1))
|
||||
}
|
||||
|
||||
func RandUInt32() uint32 {
|
||||
func RandUint32() uint32 {
|
||||
return rand.Uint32()
|
||||
}
|
||||
|
||||
func RandUInt64() uint64 {
|
||||
func RandUint64() uint64 {
|
||||
return uint64(rand.Uint32())<<32 + uint64(rand.Uint32())
|
||||
}
|
||||
|
||||
func RandUInt() uint {
|
||||
func RandUint() uint {
|
||||
return uint(rand.Int())
|
||||
}
|
||||
|
||||
// Distributed pseudo-exponentially to test for various cases
|
||||
func RandUInt16Exp() uint16 {
|
||||
func RandUint16Exp() uint16 {
|
||||
bits := rand.Uint32() % 16
|
||||
if bits == 0 {
|
||||
return 0
|
||||
@@ -74,7 +74,7 @@ func RandUInt16Exp() uint16 {
|
||||
}
|
||||
|
||||
// Distributed pseudo-exponentially to test for various cases
|
||||
func RandUInt32Exp() uint32 {
|
||||
func RandUint32Exp() uint32 {
|
||||
bits := rand.Uint32() % 32
|
||||
if bits == 0 {
|
||||
return 0
|
||||
@@ -85,7 +85,7 @@ func RandUInt32Exp() uint32 {
|
||||
}
|
||||
|
||||
// Distributed pseudo-exponentially to test for various cases
|
||||
func RandUInt64Exp() uint64 {
|
||||
func RandUint64Exp() uint64 {
|
||||
bits := rand.Uint32() % 64
|
||||
if bits == 0 {
|
||||
return 0
|
||||
@@ -96,7 +96,7 @@ func RandUInt64Exp() uint64 {
|
||||
}
|
||||
|
||||
func RandTime() time.Time {
|
||||
return time.Unix(int64(RandUInt64Exp()), 0)
|
||||
return time.Unix(int64(RandUint64Exp()), 0)
|
||||
}
|
||||
|
||||
func RandBytes(n int) []byte {
|
||||
|
||||
Reference in New Issue
Block a user