diff --git a/pkg/hnsw/heap.go b/pkg/hnsw/heap.go index 3fcdb6a..0937f40 100644 --- a/pkg/hnsw/heap.go +++ b/pkg/hnsw/heap.go @@ -76,14 +76,14 @@ func (d *DistHeap) PopMinItem() (*Item, error) { return nil, EmptyHeapError } - return Pop(d).(*Item), nil + return Pop(d), nil } func (d *DistHeap) PopMaxItem() (*Item, error) { if d.IsEmpty() { return nil, EmptyHeapError } - return PopMax(d).(*Item), nil + return PopMax(d), nil } func (d *DistHeap) Insert(id Id, dist float32) { if d.visited[id] { diff --git a/pkg/hnsw/minmax.go b/pkg/hnsw/minmax.go index 96d4fc3..ebcc0da 100644 --- a/pkg/hnsw/minmax.go +++ b/pkg/hnsw/minmax.go @@ -136,7 +136,7 @@ func Push(h Interface, x *Item) { // Pop removes and returns the minimum element (according to Less) from the heap. // The complexity is O(log n) where n = h.Len(). -func Pop(h Interface) interface{} { +func Pop(h Interface) *Item { n := h.Len() - 1 h.Swap(0, n) down(h, 0, n) @@ -145,7 +145,7 @@ func Pop(h Interface) interface{} { // PopMax removes and returns the maximum element (according to Less) from the heap. // The complexity is O(log n) where n = h.Len(). -func PopMax(h Interface) interface{} { +func PopMax(h Interface) *Item { n := h.Len() i := 0