Skip to content

Commit

Permalink
Distance gaines Less() method
Browse files Browse the repository at this point in the history
  • Loading branch information
distributed committed Jan 21, 2010
1 parent fee9d90 commit c4fde34
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,27 @@ func BucketNo(d Distance) uint {

return basebitnr
}


func (a Distance) Less(b Distance) bool {
if len(a) != len(b) {
panicln("comparing distances of different lengths")
}

//fmt.Printf("distance Less called: %v < %v\n", a, b)

for i, ea := range(a) {
eb := b[i]
switch {
case ea < eb:
//fmt.Printf("got < due to %x < %x\n", ea, eb)
return true
case ea > eb:
//fmt.Printf("got > due to %x > %x\n", ea, eb)
return false
default:
//fmt.Printf("got == due to %x == %x\n", ea, eb)
}
}
return false
}

0 comments on commit c4fde34

Please sign in to comment.