2014-05-19 20:46:41 -07:00
|
|
|
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 {
|
2014-05-19 20:46:41 -07:00
|
|
|
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 {
|
2014-05-19 20:46:41 -07:00
|
|
|
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-19 20:46:41 -07:00
|
|
|
}
|
|
|
|
|
2014-05-21 16:24:50 -07:00
|
|
|
func (self ByteSlice) Equals(other Key) bool {
|
2014-05-19 20:46:41 -07:00
|
|
|
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 {
|
2014-05-19 20:46:41 -07:00
|
|
|
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)
|
2014-05-19 20:46:41 -07:00
|
|
|
}
|