tendermint/merkle/string.go

47 lines
848 B
Go
Raw Normal View History

package merkle
import "bytes"
type String string
type ByteSlice []byte
2014-05-21 16:24:50 -07:00
func (self String) Equals(other Key) bool {
if o, ok := other.(String); ok {
return self == o
} else {
return false
}
}
2014-05-21 16:24:50 -07:00
func (self String) Less(other Key) bool {
if o, ok := other.(String); ok {
return self < o
} else {
return false
}
}
2014-05-21 16:24:50 -07:00
func (self String) Bytes() []byte {
return []byte(self)
}
2014-05-21 16:24:50 -07:00
func (self ByteSlice) Equals(other Key) bool {
if o, ok := other.(ByteSlice); ok {
return bytes.Equal(self, o)
} else {
return false
}
}
2014-05-21 16:24:50 -07:00
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
}
}
2014-05-21 16:24:50 -07:00
func (self ByteSlice) Bytes() []byte {
return []byte(self)
}