sds

package
v0.0.0-...-46a60bc Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT 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] interface {
	// Enqueue appends the element `e` at the tail of the queue.
	// If the queue is bounded, and the number of existing elements
	// equals the capacity, then Enqueue returns false without
	// modifiying the queue; otherwise Enqueue returns true.
	Enqueue(e T) bool

	// Dequeue removes the element at the head of the queue.
	// If the queue is empty, then Dequeue returns (zero,false) without
	// modifying the queue; otherwise Dequeue returns (element,true).
	Dequeue() (T, bool)

	// Capacity returns the maximum number of elements that are
	// allowed in the bounded queue. If the queue is unbounded,
	// then Capacity returns -1.
	Capacity() int

	// CurrentUse returns the number of elements currently in the queue.
	CurrentUse() int

	// PeakUse returns the maximum number of elements that have been in the queue.
	PeakUse() int
}

The type Queue specifies a first-in, first-out, goroutine-safe queue.

func NewBoundedQueue

func NewBoundedQueue[T any](capacity int) Queue[T]

NewBoundedQueue returns a bounded queue that allows the maximum of `capacity` elements.

Jump to

Keyboard shortcuts

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