buffer

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockingDeque

type BlockingDeque[T any] interface {
	Deque[T]

	// Close and empty the deque.
	Close()
}

func NewUnboundedBlockingDeque

func NewUnboundedBlockingDeque[T any](initSize int) BlockingDeque[T]

Returns a new unbounded deque with the given initial size. Note that the returned deque is always empty -- [initSize] is just a hint to prevent unnecessary resizing.

type Deque

type Deque[T any] interface {
	// Place an element at the leftmost end of the deque.
	// Returns true if the element was placed in the deque.
	PushLeft(T) bool
	// Place an element at the rightmost end of the deque.
	// Returns true if the element was placed in the deque.
	PushRight(T) bool
	// Remove and return the leftmost element of the deque.
	// Returns false if the deque is empty.
	PopLeft() (T, bool)
	// Remove and return the rightmost element of the deque.
	// Returns false if the deque is empty.
	PopRight() (T, bool)
	// Return the leftmost element of the deque without removing it.
	// Returns false if the deque is empty.
	PeekLeft() (T, bool)
	// Return the rightmost element of the deque without removing it.
	// Returns false if the deque is empty.
	PeekRight() (T, bool)
	// Returns the number of elements in the deque.
	Len() int
}

An unbounded deque (double-ended queue). See https://en.wikipedia.org/wiki/Double-ended_queue Not safe for concurrent access.

func NewUnboundedDeque

func NewUnboundedDeque[T any](initSize int) Deque[T]

Returns a new unbounded deque with the given initial slice size. Note that the returned deque is always empty -- [initSize] is just a hint to prevent unnecessary resizing.

Jump to

Keyboard shortcuts

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