deque

package
v0.0.0-...-a4a72b7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package deque implements a Double Ended Queue data structure.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyDequeue = errors.New("DoublyEnded queue is empty, so can't perform this operation")

ErrEmptyDequeue is a custom error for handling cases when some dequeuing operation is performed on an empty deque.

Functions

This section is empty.

Types

type DoublyEndedQueue

type DoublyEndedQueue[T any] struct {
	// contains filtered or unexported fields
}

func New

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

New returns a new DoublyEndedQueue.

func (*DoublyEndedQueue[T]) DequeueFront

func (dq *DoublyEndedQueue[T]) DequeueFront() (T, error)

DequeueFront deletes an item from front of Deque and returns it.

func (*DoublyEndedQueue[T]) DequeueRear

func (dq *DoublyEndedQueue[T]) DequeueRear() (T, error)

DequeueRear deletes an item from rear of Deque and returns it.

func (*DoublyEndedQueue[T]) EnqueueFront

func (dq *DoublyEndedQueue[T]) EnqueueFront(item T)

EnqueueFront adds an item at the front of Deque.

func (*DoublyEndedQueue[T]) EnqueueRear

func (dq *DoublyEndedQueue[T]) EnqueueRear(item T)

EnqueueRear adds an item at the rear of Deque.

func (*DoublyEndedQueue[T]) Front

func (dq *DoublyEndedQueue[T]) Front() (T, error)

Front gets the front item from queue.

func (*DoublyEndedQueue[T]) IsEmpty

func (dq *DoublyEndedQueue[T]) IsEmpty() bool

IsEmpty checks whether Deque is empty or not.

func (*DoublyEndedQueue[T]) Length

func (dq *DoublyEndedQueue[T]) Length() int

Length gets the length of Deque.

func (*DoublyEndedQueue[T]) Rear

func (dq *DoublyEndedQueue[T]) Rear() (T, error)

Rear gets the last item from queue.

Jump to

Keyboard shortcuts

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