|
@ -1,5 +1,8 @@ |
|
|
package merkle |
|
|
package merkle |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
"encoding/binary" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
type Int8 int8 |
|
|
type Int8 int8 |
|
|
type UInt8 uint8 |
|
|
type UInt8 uint8 |
|
@ -13,7 +16,7 @@ type Int int |
|
|
type UInt uint |
|
|
type UInt uint |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self Int8) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int8) Equals(other Key) bool { |
|
|
if o, ok := other.(Int8); ok { |
|
|
if o, ok := other.(Int8); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -21,7 +24,7 @@ func (self Int8) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int8) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int8) Less(other Key) bool { |
|
|
if o, ok := other.(Int8); ok { |
|
|
if o, ok := other.(Int8); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -29,12 +32,12 @@ func (self Int8) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int8) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self Int8) Bytes() []byte { |
|
|
|
|
|
return []byte{byte(self)} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self UInt8) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt8) Equals(other Key) bool { |
|
|
if o, ok := other.(UInt8); ok { |
|
|
if o, ok := other.(UInt8); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -42,7 +45,7 @@ func (self UInt8) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt8) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt8) Less(other Key) bool { |
|
|
if o, ok := other.(UInt8); ok { |
|
|
if o, ok := other.(UInt8); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -50,12 +53,12 @@ func (self UInt8) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt8) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self UInt8) Bytes() []byte { |
|
|
|
|
|
return []byte{byte(self)} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self Int16) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int16) Equals(other Key) bool { |
|
|
if o, ok := other.(Int16); ok { |
|
|
if o, ok := other.(Int16); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -63,7 +66,7 @@ func (self Int16) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int16) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int16) Less(other Key) bool { |
|
|
if o, ok := other.(Int16); ok { |
|
|
if o, ok := other.(Int16); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -71,12 +74,14 @@ func (self Int16) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int16) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self Int16) Bytes() []byte { |
|
|
|
|
|
b := [2]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint16(b[:], uint16(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self UInt16) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt16) Equals(other Key) bool { |
|
|
if o, ok := other.(UInt16); ok { |
|
|
if o, ok := other.(UInt16); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -84,7 +89,7 @@ func (self UInt16) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt16) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt16) Less(other Key) bool { |
|
|
if o, ok := other.(UInt16); ok { |
|
|
if o, ok := other.(UInt16); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -92,12 +97,14 @@ func (self UInt16) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt16) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self UInt16) Bytes() []byte { |
|
|
|
|
|
b := [2]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint16(b[:], uint16(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self Int32) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int32) Equals(other Key) bool { |
|
|
if o, ok := other.(Int32); ok { |
|
|
if o, ok := other.(Int32); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -105,7 +112,7 @@ func (self Int32) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int32) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int32) Less(other Key) bool { |
|
|
if o, ok := other.(Int32); ok { |
|
|
if o, ok := other.(Int32); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -113,12 +120,14 @@ func (self Int32) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int32) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self Int32) Bytes() []byte { |
|
|
|
|
|
b := [4]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint32(b[:], uint32(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self UInt32) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt32) Equals(other Key) bool { |
|
|
if o, ok := other.(UInt32); ok { |
|
|
if o, ok := other.(UInt32); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -126,7 +135,7 @@ func (self UInt32) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt32) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt32) Less(other Key) bool { |
|
|
if o, ok := other.(UInt32); ok { |
|
|
if o, ok := other.(UInt32); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -134,12 +143,14 @@ func (self UInt32) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt32) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self UInt32) Bytes() []byte { |
|
|
|
|
|
b := [4]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint32(b[:], uint32(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self Int64) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int64) Equals(other Key) bool { |
|
|
if o, ok := other.(Int64); ok { |
|
|
if o, ok := other.(Int64); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -147,7 +158,7 @@ func (self Int64) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int64) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int64) Less(other Key) bool { |
|
|
if o, ok := other.(Int64); ok { |
|
|
if o, ok := other.(Int64); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -155,12 +166,14 @@ func (self Int64) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int64) Hash() int { |
|
|
|
|
|
return int(self>>32) ^ int(self) |
|
|
|
|
|
|
|
|
func (self Int64) Bytes() []byte { |
|
|
|
|
|
b := [8]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint64(b[:], uint64(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self UInt64) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt64) Equals(other Key) bool { |
|
|
if o, ok := other.(UInt64); ok { |
|
|
if o, ok := other.(UInt64); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -168,7 +181,7 @@ func (self UInt64) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt64) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt64) Less(other Key) bool { |
|
|
if o, ok := other.(UInt64); ok { |
|
|
if o, ok := other.(UInt64); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -176,12 +189,14 @@ func (self UInt64) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt64) Hash() int { |
|
|
|
|
|
return int(self>>32) ^ int(self) |
|
|
|
|
|
|
|
|
func (self UInt64) Bytes() []byte { |
|
|
|
|
|
b := [8]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint64(b[:], uint64(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self Int) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int) Equals(other Key) bool { |
|
|
if o, ok := other.(Int); ok { |
|
|
if o, ok := other.(Int); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -189,7 +204,7 @@ func (self Int) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self Int) Less(other Key) bool { |
|
|
if o, ok := other.(Int); ok { |
|
|
if o, ok := other.(Int); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -197,12 +212,14 @@ func (self Int) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self Int) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self Int) Bytes() []byte { |
|
|
|
|
|
b := [8]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint64(b[:], uint64(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self UInt) Equals(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt) Equals(other Key) bool { |
|
|
if o, ok := other.(UInt); ok { |
|
|
if o, ok := other.(UInt); ok { |
|
|
return self == o |
|
|
return self == o |
|
|
} else { |
|
|
} else { |
|
@ -210,7 +227,7 @@ func (self UInt) Equals(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt) Less(other Sortable) bool { |
|
|
|
|
|
|
|
|
func (self UInt) Less(other Key) bool { |
|
|
if o, ok := other.(UInt); ok { |
|
|
if o, ok := other.(UInt); ok { |
|
|
return self < o |
|
|
return self < o |
|
|
} else { |
|
|
} else { |
|
@ -218,8 +235,8 @@ func (self UInt) Less(other Sortable) bool { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self UInt) Hash() int { |
|
|
|
|
|
return int(self) |
|
|
|
|
|
|
|
|
func (self UInt) Bytes() []byte { |
|
|
|
|
|
b := [8]byte{} |
|
|
|
|
|
binary.LittleEndian.PutUint64(b[:], uint64(self)) |
|
|
|
|
|
return b[:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|