Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeapItem ¶
type HeapItem interface { Data() interface{} // The data object Score() float64 // Score to use as the sort criteria }
HeapItem is an interface type implemented by objects stored in the ScoreHeap
type ScoreHeap ¶
type ScoreHeap struct {
// contains filtered or unexported fields
}
A ScoreHeap implements heap.Interface and is a min heap that keeps the top K elements by Score. Push can be called with an arbitrary number of values but only the top K are stored
func NewScoreHeap ¶
func (*ScoreHeap) GetItemsReverse ¶
func (pq *ScoreHeap) GetItemsReverse() []interface{}
GetItemsReverse returns the items in this min heap in reverse order sorted by score descending
func (*ScoreHeap) Pop ¶
func (pq *ScoreHeap) Pop() interface{}
Push implements heap.Interface and returns the top K scoring elements in increasing order of Score. Callers must reverse the order of returned elements to get the top K scoring elements in descending order
Click to show internal directories.
Click to hide internal directories.