Documentation
¶
Overview ¶
heap.Interface implementation inspired by https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/internal/heap/heap.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heap ¶
type Heap[T any] 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[T any](keyFn keyFunc[T], lessFn lessFunc[T]) *Heap[T]
New returns a Heap which can be used to queue up items to process.
func (*Heap[T]) GetByKey ¶
func (h *Heap[T]) GetByKey(key string) *T
GetByKey returns the requested item, or sets exists=false.
func (*Heap[T]) PushIfNotPresent ¶
func (h *Heap[T]) PushIfNotPresent(obj *T) (added bool)
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[T]) PushOrUpdate ¶
func (h *Heap[T]) PushOrUpdate(obj *T)
PushOrUpdate inserts an item to the queue. The item will be updated if it already exists.
Click to show internal directories.
Click to hide internal directories.