queue

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0, BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue[T any] struct {
	*queue.Queue
}

Queue represents a ring buffer.

func New

func New[T any](capacity int) *Queue[T]

New creates a new queue with the specified capacity.

func (*Queue[T]) Offer

func (queue *Queue[T]) Offer(element T) bool

Offer adds an element to the queue and returns true. If the queue is full, it drops it and returns false.

func (*Queue[T]) Poll

func (queue *Queue[T]) Poll() (element T, success bool)

Poll returns and removes the oldest element in the queue and true if successful. If returns false if the queue is empty.

Jump to

Keyboard shortcuts

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