mem

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

package mem provides an in-memory implementation of a queue data structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue[T types.Marshallable] struct {
	// contains filtered or unexported fields
}

Queue is a thread-safe FIFO queue implementation.

func NewQueue

func NewQueue[T types.Marshallable]() *Queue[T]

NewQueue creates a new Queue instance.

func (*Queue[T]) Delete

func (q *Queue[T]) Delete(string) error

Delete is no-op for the in-memory queue (already deleted by receiving).

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

Len returns the number of elements currently in the queue.

func (*Queue[T]) Push

func (q *Queue[T]) Push(val T) (string, error)

Push adds a value to the back of the queue.

func (*Queue[T]) Receive

func (q *Queue[T]) Receive() (string, T, bool)

Pop returns the value at the front of the queue without removing it. The second return value indicates if the operation succeeded.

func (*Queue[T]) ReceiveMany

func (q *Queue[T]) ReceiveMany(num int32) ([]string, []T, error)

Jump to

Keyboard shortcuts

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