bit: added .Equal() and .Len()

pull/1/head
Wijnand Modderman-Lenstra 9 years ago
parent 95fe1d034c
commit 3603905b6f

@ -38,9 +38,26 @@ func (bits *Bits) Bytes() []byte {
return o return o
} }
func (bits *Bits) String() string { func (bits Bits) Equal(other Bits) bool {
var l = bits.Len()
if l != other.Len() {
return false
}
for i := 0; i < l; i++ {
if bits[i] != other[i] {
return false
}
}
return true
}
func (bits Bits) Len() int {
return len(bits)
}
func (bits Bits) String() string {
var s = "" var s = ""
for _, b := range *bits { for _, b := range bits {
if b == 0x01 { if b == 0x01 {
s += "1" s += "1"
} else { } else {

Loading…
Cancel
Save