deque

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package deque forked from https://github.com/oleiade/lane

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deque

type Deque struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Deque is a head-tail linked list data structure implementation. It is based on a double linked list container, so that every operation's time complexity is O(1).

Every operation and Deque instances are synchronized and safe for concurrent usage.

func New

func New() *Deque

New creates a Deque

func NewCapped

func NewCapped(capacity int) *Deque

NewCapped creates a Deque with the specified capacity limit

func (*Deque) Append

func (s *Deque) Append(item interface{}) bool

Append inserts item at the back of the Deque in a O(1) time complexity, returning true if successful or false if the deque is at max capacity

func (*Deque) Capacity

func (s *Deque) Capacity() int

Capacity returns the capacity of the Deque, or -1 if unlimited

func (*Deque) Empty

func (s *Deque) Empty() bool

Empty checks if the Deque is empty

func (*Deque) First

func (s *Deque) First() interface{}

First returns the first value stored in the Deque in a O(1) time complexity

func (*Deque) Full

func (s *Deque) Full() bool

Full checks if the Deque is full

func (*Deque) IterFirst

func (s *Deque) IterFirst() *list.Element

IterFirst returns the front internal list iterator

func (*Deque) IterLast

func (s *Deque) IterLast() *list.Element

IterLast returns the back internal list iterator

func (*Deque) Last

func (s *Deque) Last() interface{}

Last returns the last value stored in the Deque in a O(1) time complexity

func (*Deque) Pop

func (s *Deque) Pop() interface{}

Pop removes the last element of the Deque in a O(1) time complexity

func (*Deque) Prepend

func (s *Deque) Prepend(item interface{}) bool

Prepend inserts item at the front of the Deque in a O(1) time complexity, returning true if successful or false if the deque is at max capacity

func (*Deque) Shift

func (s *Deque) Shift() interface{}

Shift removes the first element of the Deque in a O(1) time complexity

func (*Deque) Size

func (s *Deque) Size() int

Size returns the actual Deque size

Jump to

Keyboard shortcuts

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