package heap
import "k8s.io/kubernetes/pkg/scheduler/internal/heap"
Index ¶
- type Heap
- func New(keyFn KeyFunc, lessFn lessFunc) *Heap
- func NewWithRecorder(keyFn KeyFunc, lessFn lessFunc, metricRecorder metrics.MetricRecorder) *Heap
- func (h *Heap) Add(obj interface{}) error
- func (h *Heap) AddIfNotPresent(obj interface{}) error
- func (h *Heap) Delete(obj interface{}) error
- func (h *Heap) Get(obj interface{}) (interface{}, bool, error)
- func (h *Heap) GetByKey(key string) (interface{}, bool, error)
- func (h *Heap) Len() int
- func (h *Heap) List() []interface{}
- func (h *Heap) Peek() interface{}
- func (h *Heap) Pop() (interface{}, error)
- func (h *Heap) Update(obj interface{}) error
- type KeyFunc
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 ¶
New returns a Heap which can be used to queue up items to process.
func NewWithRecorder ¶
func NewWithRecorder(keyFn KeyFunc, lessFn lessFunc, metricRecorder metrics.MetricRecorder) *Heap
NewWithRecorder wraps an optional metricRecorder to compose a Heap object.
func (*Heap) Add ¶
Add inserts an item, and puts it in the queue. The item is updated if it already exists.
func (*Heap) AddIfNotPresent ¶
AddIfNotPresent inserts an item, and puts it in the queue. If an item with the key is present in the map, no changes is made to the item.
func (*Heap) Delete ¶
Delete removes an item.
func (*Heap) Get ¶
Get returns the requested item, or sets exists=false.
func (*Heap) GetByKey ¶
GetByKey returns the requested item, or sets exists=false.
func (*Heap) Len ¶
Len returns the number of items in the heap.
func (*Heap) List ¶
func (h *Heap) List() []interface{}
List returns a list of all the items.
func (*Heap) Peek ¶
func (h *Heap) Peek() interface{}
Peek returns the head of the heap without removing it.
func (*Heap) Pop ¶
Pop returns the head of the heap and removes it.
func (*Heap) Update ¶
Update is the same as Add in this implementation. When the item does not exist, it is added.
type KeyFunc ¶
KeyFunc is a function type to get the key from an object.
Source Files ¶
heap.go
- Version
- v1.17.8
- Published
- Jun 26, 2020
- Platform
- js/wasm
- Imports
- 4 packages
- Last checked
- 3 minutes ago –
Tools for package owners.