Documentation ¶
Overview ¶
heap.Interface implementation inspired by https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/internal/heap/heap.go
Index ¶
- type Heap
- func (h *Heap) Delete(key string)
- func (h *Heap) Get(obj interface{}) (item interface{})
- func (h *Heap) GetByKey(key string) interface{}
- func (h *Heap) Len() int
- func (h *Heap) List() []interface{}
- func (h *Heap) Pop() interface{}
- func (h *Heap) PushIfNotPresent(obj interface{}) (added bool)
- func (h *Heap) PushOrUpdate(obj interface{})
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 New ¶
func New(keyFn keyFunc, lessFn lessFunc) Heap
New returns a Heap which can be used to queue up items to process.
func (*Heap) Get ¶
func (h *Heap) Get(obj interface{}) (item interface{})
Get returns the requested item, exists, error.
func (*Heap) Pop ¶
func (h *Heap) Pop() interface{}
Pop returns the head of the heap and removes it.
func (*Heap) PushIfNotPresent ¶
PushIfNotPresent inserts an item to the queue. If an item with the key is present in the map, no changes is made to the item.
func (*Heap) PushOrUpdate ¶
func (h *Heap) PushOrUpdate(obj interface{})
PushOrUpdate inserts an item to the queue. The item will be updated if it already exists.