From c4fde34325d1e699cb02f3d4bbcc89d6876c7de5 Mon Sep 17 00:00:00 2001 From: Michael Meier Date: Thu, 21 Jan 2010 23:08:48 +0100 Subject: [PATCH] Distance gaines Less() method --- lib/utility.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/utility.go b/lib/utility.go index 223cc61..5d6fe74 100644 --- a/lib/utility.go +++ b/lib/utility.go @@ -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 +}