Documentation
¶
Index ¶
- Constants
- type MutateFunc
- type QueueHooks
- type TrackedQueue
- func (q *TrackedQueue[T]) CanAccept(itemsCount int) bool
- func (q *TrackedQueue[T]) Capacity() int
- func (q *TrackedQueue[T]) Enqueue(item T, cycle int) bool
- func (q *TrackedQueue[T]) Items() []T
- func (q *TrackedQueue[T]) Len() int
- func (q *TrackedQueue[T]) Name() string
- func (q *TrackedQueue[T]) PopFront(cycle int) (T, bool)
- func (q *TrackedQueue[T]) RemoveAt(idx int, cycle int) (T, bool)
- func (q *TrackedQueue[T]) RemoveMatch(match func(T) bool, cycle int) (T, bool)
- func (q *TrackedQueue[T]) SetCapacity(capacity int)
Constants ¶
const UnlimitedCapacity = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MutateFunc ¶
MutateFunc is invoked after queue length or capacity changes.
type QueueHooks ¶
type QueueHooks[T any] struct { OnEnqueue func(item T, cycle int) OnDequeue func(item T, cycle int) }
QueueHooks defines callbacks for queue lifecycle events.
type TrackedQueue ¶
type TrackedQueue[T any] struct { // contains filtered or unexported fields }
TrackedQueue maintains items with length/capacity bookkeeping and hooks.
func NewTrackedQueue ¶
func NewTrackedQueue[T any](name string, capacity int, mutate MutateFunc, hooks QueueHooks[T]) *TrackedQueue[T]
NewTrackedQueue constructs a tracked queue with optional hooks and mutate callback.
func (*TrackedQueue[T]) CanAccept ¶
func (q *TrackedQueue[T]) CanAccept(itemsCount int) bool
CanAccept checks if the queue can accept additional itemsCount entries respecting capacity.
func (*TrackedQueue[T]) Capacity ¶
func (q *TrackedQueue[T]) Capacity() int
Capacity returns current capacity (-1 for unlimited).
func (*TrackedQueue[T]) Enqueue ¶
func (q *TrackedQueue[T]) Enqueue(item T, cycle int) bool
Enqueue appends an item. Returns false if capacity exceeded.
func (*TrackedQueue[T]) Items ¶
func (q *TrackedQueue[T]) Items() []T
Items exposes the underlying slice (read-only operations only).
func (*TrackedQueue[T]) PopFront ¶
func (q *TrackedQueue[T]) PopFront(cycle int) (T, bool)
PopFront removes and returns the front item.
func (*TrackedQueue[T]) RemoveAt ¶
func (q *TrackedQueue[T]) RemoveAt(idx int, cycle int) (T, bool)
RemoveAt deletes the item at index.
func (*TrackedQueue[T]) RemoveMatch ¶
func (q *TrackedQueue[T]) RemoveMatch(match func(T) bool, cycle int) (T, bool)
RemoveMatch removes the first item matching predicate.
func (*TrackedQueue[T]) SetCapacity ¶
func (q *TrackedQueue[T]) SetCapacity(capacity int)
SetCapacity updates queue capacity and triggers mutate callback.