staque

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 6 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 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 Priority

type Priority[T PriorityItem] interface {
	Queue[T]
	Stack[T]
	Update(item T) error
	Remove(item T) (T, bool)
	Items() []T
}

func NewPriority

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

New initializes an empty priority queue.

type PriorityItem

type PriorityItem interface {
	common.Unique
	common.Weighted
}

type Queue

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

type Simple

type Simple[T any] interface {
	Queue[T]
	Stack[T]
	PopN(n int) ([]T, error)
	ShiftN(n int) ([]T, error)
}

func NewSimple

func NewSimple[T any](maxSize int) Simple[T]

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

type Stack

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

Jump to

Keyboard shortcuts

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