queue

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLessFunc

func DefaultLessFunc[T PriorityItem](a, b T) bool

Types

type DoubleBufferQueue

type DoubleBufferQueue = DoubleBufferQueueG[byte]

type DoubleBufferQueueG

type DoubleBufferQueueG[T any] interface {
	Write(p []T) (int, error)
	Read(p []T) (int, error)
	io.Closer
}

func NewDoubleBufferQueue

func NewDoubleBufferQueue[T any](ctx context.Context, initialSize int, swapInterval time.Duration) DoubleBufferQueueG[T]

type Option

type Option[T PriorityItem] func(*priority[T])

func BlockIfEmpty

func BlockIfEmpty[T PriorityItem]() Option[T]

func WithLessFunc

func WithLessFunc[T PriorityItem](lf btree.LessFunc[T]) Option[T]

func WithLogger

func WithLogger[T PriorityItem](logger log.Logger) Option[T]

type PriorityItem

type PriorityItem interface {
	common.Unique
	common.Weighted
}

type PriorityQueue

type PriorityQueue[T PriorityItem] interface {
	SimpleQueue[T]
	Update(item T) error
	Remove(item T) (T, bool)
	Items() []T
}

func NewPriority

func NewPriority[T PriorityItem](opts ...Option[T]) PriorityQueue[T]

New initializes an empty priority queue.

type Queue

type Queue[T any] interface {
	SimpleQueue[T]
	Reset()
	MustGet(i int) T
	MustPop() T
	PopN(n int) ([]T, error)
	Shift() (T, error)
	MustShift() T
	ShiftN(n int) ([]T, error)
}

func New

func New[T any](maxSize int) Queue[T]

create a new simple. max size <= 0 means no size limit.

type SimpleQueue

type SimpleQueue[T any] interface {
	Length() int
	IsEmpty() bool
	Push(element ...T)
	Pop() (T, error)
	Reset()
}

Jump to

Keyboard shortcuts

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