Documentation
¶
Index ¶
- type IterationCallback
- type IterationDirection
- type Q
- func (q *Q[T]) At(index int) (T, bool)
- func (q *Q[T]) Clear()
- func (q *Q[T]) Dequeue() (T, bool)
- func (q *Q[T]) Enqueue(item T)
- func (q *Q[T]) ForEach(callback IterationCallback[T])
- func (q *Q[T]) ForEachReverse(callback IterationCallback[T])
- func (q *Q[T]) Len() int
- func (q *Q[T]) Peek() (T, bool)
- func (q *Q[T]) Pop() (T, bool)
- func (q *Q[T]) Push(item T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IterationCallback ¶ added in v1.8.9
type IterationDirection ¶ added in v1.8.9
type IterationDirection bool
IterationDirection specifies the direction in which to iterate over the items
const ( Forward IterationDirection = true Backward IterationDirection = false )
type Q ¶
type Q[T any] struct { // contains filtered or unexported fields }
Q is a generic stack/queue structure that supports both stack and queue operations. Stack operations (Push/Pop) are O(1) Queue operations (Enqueue/Dequeue) are O(1) amortized for Enqueue, O(n) for Dequeue
func (*Q[T]) Enqueue ¶
func (q *Q[T]) Enqueue(item T)
Enqueue adds an item to the end of the queue (queue behavior)
func (*Q[T]) ForEach ¶ added in v1.8.9
func (q *Q[T]) ForEach(callback IterationCallback[T])
ForEach allows you to iterate over the items (from front to back)
func (*Q[T]) ForEachReverse ¶ added in v1.8.9
func (q *Q[T]) ForEachReverse(callback IterationCallback[T])
ForEachReverse allows you to iterate over the items (from back to front)
Click to show internal directories.
Click to hide internal directories.