Documentation ¶
Index ¶
- type Heap
- func (h *Heap[K, V]) Add(obj V) error
- func (h *Heap[K, V]) AddIfNotPresent(obj V) error
- func (h *Heap[K, V]) BulkAdd(list []V) error
- func (h *Heap[K, V]) Close()
- func (h *Heap[K, V]) Delete(obj V) error
- func (h *Heap[K, V]) Get(obj V) (V, bool, error)
- func (h *Heap[K, V]) GetByKey(key K) (V, bool, error)
- func (h *Heap[K, V]) IsClosed() bool
- func (h *Heap[K, V]) List() []V
- func (h *Heap[K, V]) ListKeys() []K
- func (h *Heap[K, V]) Peek() (V, error)
- func (h *Heap[K, V]) Pop() (V, error)
- func (h *Heap[K, V]) Update(obj V) 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[K comparable, V any] struct { // contains filtered or unexported fields }
Heap is a thread-safe producer/consumer queue that implements a heap data structure.
func NewHeap ¶
func NewHeap[K comparable, V any](keyFn KeyFunc[K, V], lessFn LessFunc[V]) *Heap[K, V]
NewHeap returns a Heap which can be used to queue up items to process.
func (*Heap[K, V]) AddIfNotPresent ¶
AddIfNotPresent adds an object if it does not already exist.
func (*Heap[K, V]) List ¶
func (h *Heap[K, V]) List() []V
List returns a list of all objects in the heap.
func (*Heap[K, V]) ListKeys ¶
func (h *Heap[K, V]) ListKeys() []K
ListKeys returns a list of all keys in the heap.
type KeyFunc ¶
type KeyFunc[K comparable, V any] func(V) (K, error)
KeyFunc is used to generate a key for an object.
Click to show internal directories.
Click to hide internal directories.