Documentation
¶
Index ¶
- type Heap
- func (h *Heap) AddIfNotPresent(obj interface{}) error
- func (h *Heap) AddOrUpdate(obj interface{}) error
- func (h *Heap) GetByKey(key string) (interface{}, bool)
- func (h *Heap) Len() int
- func (h *Heap) List() []interface{}
- func (h *Heap) Peek() interface{}
- func (h *Heap) PeekSecond() interface{}
- func (h *Heap) Pop() interface{}
- func (h *Heap) Range(f func(i int, key string, obj interface{}) bool)
- func (h *Heap) Remove(obj interface{}) error
- func (h *Heap) UpdateIfPresent(obj interface{}) error
- type KeyError
- type KeyFunc
- type LessFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heap ¶
type Heap struct {
// contains filtered or unexported fields
}
Heap is a producer/consumer queue that implements a heap data structure. It can be used to implement priority queues and similar data structures.
func (*Heap) AddIfNotPresent ¶
AddIfNotPresent inserts an item, and puts it in the queue. If an item with the key is present in the heap, no changes is made to the item.
func (*Heap) AddOrUpdate ¶
Add inserts an item, and puts it in the queue. The item is updated if it already exists.
func (*Heap) Peek ¶
func (h *Heap) Peek() interface{}
Peek returns the head of the heap without removing it.
func (*Heap) PeekSecond ¶
func (h *Heap) PeekSecond() interface{}
PeekSecond returns the second item of heap without removing it.
func (*Heap) Pop ¶
func (h *Heap) Pop() interface{}
Pop returns the head of the heap and removes it.
func (*Heap) Range ¶
Range calls f sequentially for each key and value present in the heap. If f returns false, range stops the iteration.
Range does not guarantee the order.
func (*Heap) UpdateIfPresent ¶
UpdateIfPresent update an item's obj and fix the order if it is present in the heap.