koda

package module
v0.0.0-...-7d75307 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueFull = errors.New("queue is empty")

Functions

This section is empty.

Types

type Comparor

type Comparor[T any] interface {
	Compare(other T) bool
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL