Documentation ¶
Index ¶
- type Queue
- func (q *Queue[T]) Dequeue() (T, bool)
- func (q *Queue[T]) DequeueFromEnd() (T, bool)
- func (q *Queue[T]) Enqueue(v T)
- func (q *Queue[T]) InsertAt(index int, v T)
- func (q *Queue[T]) Peek() (T, bool)
- func (q *Queue[T]) PeekAt(index int) (T, bool)
- func (q *Queue[T]) PeekEnd() (T, bool)
- func (q *Queue[T]) RemoveAt(index int) (T, bool)
- func (q *Queue[T]) Reset()
- func (q *Queue[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue is a generic FIFO queue implementation in Go.
func (*Queue[T]) Dequeue ¶
Dequeue removes the value at the front of the queue and returns it. If the queue is empty, it returns the zero value of the type T and a boolean false.
func (*Queue[T]) DequeueFromEnd ¶
DequeueFromEnd removes the value at the end of the queue and returns it. If the queue is empty, it returns the zero value of the type T and a boolean false.
func (*Queue[T]) Enqueue ¶
func (q *Queue[T]) Enqueue(v T)
Enqueue adds a value to the back of the queue.
func (*Queue[T]) InsertAt ¶
InsertAt inserts an element at a specified index in the queue. If the index is out of range, it will append the element at the end.
func (*Queue[T]) Peek ¶
Peek returns the value at the front of the queue without removing it. If the queue is empty, it returns the zero value of the type T and a boolean false.
func (*Queue[T]) PeekAt ¶
PeekAt returns the value at the specified index without removing it. Returns the peeked element and true if successful, zero value and false if not.
func (*Queue[T]) PeekEnd ¶
PeekEnd returns the value at the end of the queue without removing it. If the queue is empty, it returns the zero value of the type T and a boolean false.