Documentation
¶
Index ¶
- type 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) DeleteByKey(key string) 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) Process(f ProcessFunc)
- func (h *Heap) String() string
- func (h *Heap) Update(oldObj, newObj interface{}) error
- type KeyFunc
- type ProcessFunc
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 NewWithRecorder ¶
func NewWithRecorder(name string, 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) DeleteByKey ¶
DeleteByKey removes an item by key.
func (*Heap) Peek ¶
func (h *Heap) Peek() interface{}
Peek returns the head of the heap without removing it.
type ProcessFunc ¶
ProcessFunc is a function type to process each item in parallel. It MUST be a read-only function.