Documentation ¶
Index ¶
- type Heap
- func (h *Heap) Add(obj interface{}) error
- func (h *Heap) AddIfNotPresent(obj interface{}) error
- func (h *Heap) BulkAdd(list []interface{}) error
- func (h *Heap) Close()
- func (h *Heap) Delete(obj interface{}) error
- func (h *Heap) Get(obj interface{}) (interface{}, bool)
- func (h *Heap) GetByKey(key string) (interface{}, bool)
- func (h *Heap) IsClosed() bool
- func (h *Heap) List() []interface{}
- func (h *Heap) ListKeys() []string
- func (h *Heap) Pop() (interface{}, error)
- func (h *Heap) Update(obj interface{}) error
- type KeyFunc
- type LessFunc
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 thread-safe producer/consumer queue that implements a heap data structure. It can be used to implement priority queues and similar data structures.
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.
This is useful in a single producer/consumer scenario so that the consumer can safely retry items without contending with the producer and potentially enqueueing stale items.
func (*Heap) BulkAdd ¶
BulkAdd adds all the items in the list to the queue and then signals the condition variable. It is useful when the caller would like to add all of the items to the queue before consumer starts processing them.
func (*Heap) Close ¶
func (h *Heap) Close()
Close the Heap and signals condition variables that may be waiting to pop items from the heap.
func (*Heap) ListKeys ¶
ListKeys returns a list of all the keys of the objects currently in the Heap.