Documentation
¶
Overview ¶
Package heap provides the implementation for heaps.
Index ¶
- type Heap
- func (h *Heap) Len() int
- func (h *Heap) Less(i, j int) bool
- func (h *Heap) Peek() float64
- func (h *Heap) Pop() interface{}
- func (h *Heap) Push(x interface{})
- func (h *Heap) Remove(item *Item)
- func (h *Heap) Swap(i, j int)
- func (h *Heap) Update(item *Item, val float64)
- func (h *Heap) Values() []float64
- type Item
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heap ¶
type Heap struct { ID string // contains filtered or unexported fields }
Heap implements a heap data structure.
func (*Heap) Pop ¶
func (h *Heap) Pop() interface{}
Pop removes element Len() - 1 from the heap. This satisfies heapops.Interface.
func (*Heap) Push ¶
func (h *Heap) Push(x interface{})
Push adds an element to the heap. This satisfies heapops.Interface.
type Item ¶
type Item struct { Val float64 // field that can be used for bookkeeping (i.e. // keeping track of the item as it gets moved // between multiple heaps; this is useful for // HeapMedian) HeapID string // contains filtered or unexported fields }
Item represents an item in the heap; in particular, it contains not only the value, but also the index of the item within the heap. This is useful for the case where we want to replace an item in the heap and fix its structure; the container/heap.Fix method requires the index of the item that possibly violates the heap invariant.
Click to show internal directories.
Click to hide internal directories.