deque

package module
v1.0.0-...-c8c1a1f Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: BSD-2-Clause Imports: 2 Imported by: 2

README

go-deque

Build Status Go Reference Go Report Card codecov

A simple, generic, thread-safe implementation of double-ended queue in Go.

Installation

Install go-deque by executing the following command.

go get -v gopkg.in/dnaeon/go-deque.v1

Usage

See the included test cases for some examples.

Tests

Run the tests.

make test

License

go-deque is Open Source and licensed under the BSD License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyQueue = errors.New("Queue is empty")

ErrEmptyQueue is an error which is returned when attempting to pop an item from an empty queue

Functions

This section is empty.

Types

type Deque

type Deque[T any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New[T any]() *Deque[T]

New creates a new deque

func (*Deque[T]) IsEmpty

func (d *Deque[T]) IsEmpty() bool

IsEmpty returns true if the deque is empty, false otherwise

func (*Deque[T]) Length

func (d *Deque[T]) Length() int

Length returns the size of the queue

func (*Deque[T]) PeekBack

func (d *Deque[T]) PeekBack() (T, error)

PeekBack peeks at the back

func (*Deque[T]) PeekFront

func (d *Deque[T]) PeekFront() (T, error)

PeekFront peeks at the front

func (*Deque[T]) PopBack

func (d *Deque[T]) PopBack() (T, error)

PopBack pops an item from the back

func (*Deque[T]) PopFront

func (d *Deque[T]) PopFront() (T, error)

PopFront pops an item from the front

func (*Deque[T]) PushBack

func (d *Deque[T]) PushBack(value T)

PushBack inserts a new item at the back

func (*Deque[T]) PushFront

func (d *Deque[T]) PushFront(value T)

PushFront inserts a new item at the front

Jump to

Keyboard shortcuts

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