Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRequeueingQueue ¶
func NewRequeueingQueue[T any]() collection.Stack[T]
NewRequeueingQueue for a queue that never loses elements, they are just added back onto the end of the queue on pop. Useful for when you don't want to keep track of an array and an index on an object.
Types ¶
type HashPriority ¶
type HashPriority[T comparable] interface { Priority GetHash() T }
HashPriority exposes both a priority function and Hash function.
type HashPriorityQueue ¶
type HashPriorityQueue[T comparable] interface { // Size of this queue Size() int // Push the passed element onto this queue if it does not already exist in // the queue. Push(element HashPriority[T]) // Pop the highest priority element off the queue Pop() (HashPriority[T], bool) // Peek at the highest priority element without modifying the queue Peek() (HashPriority[T], bool) }
HashPriorityQueue prevents duplicate prioritized entries in a queue.
func NewHashPriorityQueue ¶
func NewHashPriorityQueue[T comparable]() HashPriorityQueue[T]
NewHashPriorityQueue for queueing unique elements by priority.
type Priority ¶
type Priority interface { // GetPriority of this element as an int where lower priority < higher priority GetPriority() int }
Priority is for use in collections that require elements to resolve their own priority.
type PriorityQueue ¶
type PriorityQueue interface { // Size of this queue Size() int // Push the passed element onto this queue Push(element Priority) // Pop the highest priority element off the queue Pop() (Priority, bool) // Peek at the highest priority element without modifying the queue Peek() (Priority, bool) }
PriorityQueue for queueing elements that implement priority and returning elements in the order of highest to lowest priority.
func NewPriorityQueue ¶
func NewPriorityQueue() PriorityQueue
NewPriorityQueue for queueing elements according to their priority
type RateHashPriorityQueue ¶
type RateHashPriorityQueue[T comparable] interface { HashPriorityQueue[T] // NoLimitPop the highest priority element off the queue ignoring the rate limit // for the purpose of batching commands NoLimitPop() (HashPriority[T], bool) // Channel that can be used instead of Pop Channel() <-chan HashPriority[T] // Stop this RateHashPriorityQueue so that it can be garbage collected. Stop() }
RateHashPriorityQueue allows prioritized unique elements to be emitted at a specific rate.
func NewRateHashPriorityQueue ¶
func NewRateHashPriorityQueue[T comparable](n int, rate time.Duration) RateHashPriorityQueue[T]
NewRateHashPriorityQueue that will return at max 'n' elements per 'rate' duration.