Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundedMinHeap ¶
type BoundedMinHeap[T any] struct { // contains filtered or unexported fields }
BoundedMinHeap maintains the best N items efficiently using an internal min-heap. It keeps the N best items according to the comparison function. The root of the internal heap is always the worst item, making it easy to remove when a better item arrives.
func NewBoundedMinHeap ¶
func NewBoundedMinHeap[T any](maxSize int, cmpFunc func(T, T) int) *BoundedMinHeap[T]
NewBoundedMinHeap creates a new bounded min-heap with the specified maximum size and comparison function.
func (*BoundedMinHeap[T]) Add ¶
func (h *BoundedMinHeap[T]) Add(item T)
Add adds an item to the bounded min-heap. If the heap is full and the new item is better than the worst item, it replaces the worst item.
func (*BoundedMinHeap[T]) Len ¶
func (h *BoundedMinHeap[T]) Len() int
Len returns the number of items in the heap.
func (*BoundedMinHeap[T]) ToSortedSlice ¶
func (h *BoundedMinHeap[T]) ToSortedSlice() []T
ToSortedSlice returns all items in the heap as a sorted slice (best to worst).
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
SyncMap is the generic version of the sync.Map.
func NewSyncMap ¶
func NewSyncMap[K comparable, V any](capacity int) SyncMap[K, V]
NewSyncMap returns a new SyncMap.
func (*SyncMap[K, V]) Delete ¶
Delete deletes the value for a key, returning the previous value if any. The exist result reports whether the key was present.