collections

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueueElementsNameSuffix   = "_elements"
	QueueFrontNameSuffix      = "_front"
	QueueRearNameSuffix       = "_rear"
	QueueElementsPrefixSuffix = 0x0
	QueueFrontPrefixSuffix    = 0x1
	QueueRearPrefixSuffix     = 0x2
)

Variables

View Source
var (
	ErrPeek             = errors.New("queue peek failed")
	ErrEmptyQueue       = errors.New("queue is empty")
	ErrOutOfBoundsQueue = errors.New("queue index is out of bounds")
)

Functions

This section is empty.

Types

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any](sb *collections.SchemaBuilder, prefix collections.Prefix, name string, vc codec.ValueCodec[T]) Queue[T]

func (Queue[T]) Dequeue

func (q Queue[T]) Dequeue(ctx context.Context) (elem T, err error)

func (Queue[T]) Enqueue

func (q Queue[T]) Enqueue(ctx context.Context, elem T) error

func (Queue[T]) Front

func (q Queue[T]) Front(ctx context.Context) (uint64, error)

func (Queue[T]) Get

func (q Queue[T]) Get(ctx context.Context, index uint64) (elem T, err error)

func (Queue[T]) Initialize

func (q Queue[T]) Initialize(ctx context.Context) error

func (Queue[T]) IsEmpty

func (q Queue[T]) IsEmpty(ctx context.Context) bool

func (Queue[T]) Iterate

func (q Queue[T]) Iterate(ctx context.Context) (collections.Iterator[uint64, T], error)

TODO: Iterate with a custom range, clamp the range to the front and rear.

func (Queue[T]) Len

func (q Queue[T]) Len(ctx context.Context) uint64

func (Queue[T]) Peek

func (q Queue[T]) Peek(ctx context.Context) (elem T, err error)

func (Queue[T]) Rear

func (q Queue[T]) Rear(ctx context.Context) (uint64, error)

Jump to

Keyboard shortcuts

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