tendermint/merkle/string.go
Jae Kwon 19726afc96 .
2014-05-21 16:24:50 -07:00

47 lines
848 B
Go

package merkle
import "bytes"
type String string
type ByteSlice []byte
func (self String) Equals(other Key) bool {
if o, ok := other.(String); ok {
return self == o
} else {
return false
}
}
func (self String) Less(other Key) bool {
if o, ok := other.(String); ok {
return self < o
} else {
return false
}
}
func (self String) Bytes() []byte {
return []byte(self)
}
func (self ByteSlice) Equals(other Key) bool {
if o, ok := other.(ByteSlice); ok {
return bytes.Equal(self, o)
} else {
return false
}
}
func (self ByteSlice) Less(other Key) bool {
if o, ok := other.(ByteSlice); ok {
return bytes.Compare(self, o) < 0 // -1 if a < b
} else {
return false
}
}
func (self ByteSlice) Bytes() []byte {
return []byte(self)
}