package heap
import "k8s.io/kubernetes/pkg/scheduler/backend/heap"
Index ¶
- type Heap
- func New[T any](keyFn KeyFunc[T], lessFn LessFunc[T]) *Heap[T]
- func NewWithRecorder[T any](keyFn KeyFunc[T], lessFn LessFunc[T], metricRecorder metrics.MetricRecorder) *Heap[T]
- func (h *Heap[T]) AddOrUpdate(obj T)
- func (h *Heap[T]) Delete(obj T) error
- func (h *Heap[T]) Get(obj T) (T, bool)
- func (h *Heap[T]) GetByKey(key string) (T, bool)
- func (h *Heap[T]) Has(obj T) bool
- func (h *Heap[T]) Len() int
- func (h *Heap[T]) List() []T
- func (h *Heap[T]) Peek() (T, bool)
- func (h *Heap[T]) Pop() (T, error)
- type KeyFunc
- type LessFunc
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 ¶
New returns a Heap which can be used to queue up items to process.
func NewWithRecorder ¶
func NewWithRecorder[T any](keyFn KeyFunc[T], lessFn LessFunc[T], metricRecorder metrics.MetricRecorder) *Heap[T]
NewWithRecorder wraps an optional metricRecorder to compose a Heap object.
func (*Heap[T]) AddOrUpdate ¶
func (h *Heap[T]) AddOrUpdate(obj T)
AddOrUpdate inserts an item, and puts it in the queue. The item is updated if it already exists.
func (*Heap[T]) Delete ¶
Delete removes an item.
func (*Heap[T]) Get ¶
Get returns the requested item, or sets exists=false.
func (*Heap[T]) GetByKey ¶
GetByKey returns the requested item, or sets exists=false.
func (*Heap[T]) Has ¶
func (*Heap[T]) Len ¶
Len returns the number of items in the heap.
func (*Heap[T]) List ¶
func (h *Heap[T]) List() []T
List returns a list of all the items.
func (*Heap[T]) Peek ¶
Peek returns the head of the heap without removing it.
func (*Heap[T]) Pop ¶
Pop returns the head of the heap and removes it.
type KeyFunc ¶
KeyFunc is a function type to get the key from an object.
type LessFunc ¶
LessFunc is a function that receives two items and returns true if the first item should be placed before the second one when the list is sorted.
Source Files ¶
heap.go
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 3 hours ago –
Tools for package owners.