Documentation ¶
Index ¶
- type Elem
- type PriorityQueue
- func (p *PriorityQueue) Clone() *PriorityQueue
- func (p *PriorityQueue) Elems() []Elem[int32, float32]
- func (e *PriorityQueue) Len() int
- func (e *PriorityQueue) Less(i, j int) bool
- func (p *PriorityQueue) Peek() (int32, float32)
- func (p *PriorityQueue) Pop() (int32, float32)
- func (p *PriorityQueue) Push(v int32, weight float32)
- func (p *PriorityQueue) Reverse() *PriorityQueue
- func (e *PriorityQueue) Swap(i, j int)
- func (p *PriorityQueue) Values() []int32
- type TopKFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elem ¶
type Elem[E any, W constraints.Ordered] struct { Value E Weight W }
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue represents the priority queue.
func NewPriorityQueue ¶
func NewPriorityQueue(desc bool) *PriorityQueue
NewPriorityQueue initializes an empty priority queue.
func (*PriorityQueue) Clone ¶
func (p *PriorityQueue) Clone() *PriorityQueue
func (*PriorityQueue) Peek ¶
func (p *PriorityQueue) Peek() (int32, float32)
func (*PriorityQueue) Pop ¶
func (p *PriorityQueue) Pop() (int32, float32)
Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, an error is returned.
func (*PriorityQueue) Push ¶
func (p *PriorityQueue) Push(v int32, weight float32)
Push inserts a new element into the queue. No action is performed on duplicate elements.
func (*PriorityQueue) Reverse ¶
func (p *PriorityQueue) Reverse() *PriorityQueue
func (*PriorityQueue) Values ¶
func (p *PriorityQueue) Values() []int32
type TopKFilter ¶
type TopKFilter[T any, W constraints.Ordered] struct { // contains filtered or unexported fields }
TopKFilter filters out top k items with maximum weights.
func NewTopKFilter ¶
func NewTopKFilter[T any, W constraints.Ordered](k int) *TopKFilter[T, W]
NewTopKFilter creates a top k filter.
func (*TopKFilter[T, W]) PopAll ¶
func (filter *TopKFilter[T, W]) PopAll() ([]T, []W)
PopAll pops all items in the filter with decreasing order.
func (*TopKFilter[T, W]) Push ¶
func (filter *TopKFilter[T, W]) Push(item T, weight W)
Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Count().
Click to show internal directories.
Click to hide internal directories.