Documentation
¶
Index ¶
- Variables
- type Comparor
- type FIFOHandler
- type HeapHandler
- func (m *HeapHandler[T]) Dequeue() (T, error)
- func (m *HeapHandler[T]) Enqueue(item T)
- func (m *HeapHandler[T]) Items() []T
- func (m *HeapHandler[T]) Len() int
- func (m *HeapHandler[T]) Less(i, j int) bool
- func (m *HeapHandler[T]) Peek() (T, error)
- func (m *HeapHandler[T]) Pop() any
- func (m *HeapHandler[T]) Push(x any)
- func (m *HeapHandler[T]) Swap(i, j int)
- type Queue
- type QueueConfig
- type QueueHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrQueueFull = errors.New("queue is empty")
Functions ¶
This section is empty.
Types ¶
type FIFOHandler ¶
type FIFOHandler[T any] struct { // contains filtered or unexported fields }
func NewFIFOHandler ¶
func NewFIFOHandler[T any]() *FIFOHandler[T]
func (*FIFOHandler[T]) Dequeue ¶
func (m *FIFOHandler[T]) Dequeue() (T, error)
func (*FIFOHandler[T]) Enqueue ¶
func (m *FIFOHandler[T]) Enqueue(item T)
func (*FIFOHandler[T]) Items ¶
func (m *FIFOHandler[T]) Items() []T
func (*FIFOHandler[T]) Len ¶
func (m *FIFOHandler[T]) Len() int
func (*FIFOHandler[T]) Peek ¶
func (m *FIFOHandler[T]) Peek() (T, error)
type HeapHandler ¶
type HeapHandler[T Comparor[T]] struct { // contains filtered or unexported fields }
The heap handler is a priority queue that implements the heap interface. The heap handler should be created with the NewHeap function or by initializing the handler and calling heap.Init on the handler.
func NewHeap ¶
func NewHeap[T Comparor[T]]() *HeapHandler[T]
func (*HeapHandler[T]) Dequeue ¶
func (m *HeapHandler[T]) Dequeue() (T, error)
func (*HeapHandler[T]) Enqueue ¶
func (m *HeapHandler[T]) Enqueue(item T)
func (*HeapHandler[T]) Items ¶
func (m *HeapHandler[T]) Items() []T
func (*HeapHandler[T]) Len ¶
func (m *HeapHandler[T]) Len() int
func (*HeapHandler[T]) Less ¶
func (m *HeapHandler[T]) Less(i, j int) bool
func (*HeapHandler[T]) Peek ¶
func (m *HeapHandler[T]) Peek() (T, error)
func (*HeapHandler[T]) Pop ¶
func (m *HeapHandler[T]) Pop() any
func (*HeapHandler[T]) Push ¶
func (m *HeapHandler[T]) Push(x any)
func (*HeapHandler[T]) Swap ¶
func (m *HeapHandler[T]) Swap(i, j int)
type Queue ¶
type Queue struct {
QueueConfig
}
func NewQueue ¶
func NewQueue(cfg QueueConfig) *Queue
type QueueConfig ¶
type QueueConfig struct { Handler QueueHandler Name string }
type QueueHandler ¶
type QueueHandler interface { Enqueue(item any) Dequeue() (any, error) Peek() (any, error) Len() int // Should return the items in the queue in the order they would be dequeued. Items() []any }
QueueHandler specifies the interface for working with a queue implementation. The handler is responsible for initializing the queue, adding and removing items, and returning the items in the queue.
Click to show internal directories.
Click to hide internal directories.