deque

package
v0.0.0-...-b7647e0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: Apache-2.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deque

type Deque interface {
	// Len returns the number of elements of Deque.
	// The complexity is O(1).
	Len() int
	// Clear clears Deque
	Clear()
	// ForEach call fn on all elements which after the offset, stopped if false returned
	ForEach(offset int, fn func(interface{}) bool)
	// Front returns the first element of Deque, false if the list is empty.
	Front() (*Element, bool)
	// PopFront removes and returns the first element of Deque
	PopFront() *Element
	// Front returns the first element of Deque, panic if the list is empty.
	MustFront() *Element
	// Back returns the last element of Deque, false if the list is empty.
	Back() (*Element, bool)
	// PopBack removes and returns the last element of Deque
	PopBack() *Element
	// MustBack returns the last element of Deque, panic if the list is empty.
	MustBack() *Element
	// PushFront inserts a new element e with value v at the front of deque.
	PushFront(v interface{}) *Element
	// PushBack inserts a new element e with value v at the back of deque.
	PushBack(v interface{}) *Element
	// InsertBefore inserts a new element e with value v immediately before mark and returns e.
	// If mark is not an element of l, the list is not modified.
	// The mark must not be nil.
	InsertBefore(v interface{}, mark *Element) *Element
	// InsertAfter inserts a new element e with value v immediately after mark and returns e.
	// If mark is not an element of l, the list is not modified.
	// The mark must not be nil.
	InsertAfter(v interface{}, mark *Element) *Element
	// MoveToFront moves element e to the front of list l.
	// If e is not an element of l, the list is not modified.
	// The element must not be nil.
	MoveToFront(e *Element)
	// MoveToBack moves element e to the back of list l.
	// If e is not an element of l, the list is not modified.
	// The element must not be nil.
	MoveToBack(e *Element)
	// MoveBefore moves element e to its new position before mark.
	// If e or mark is not an element of l, or e == mark, the list is not modified.
	// The element and mark must not be nil.
	MoveBefore(e, mark *Element)
	// MoveAfter moves element e to its new position after mark.
	// If e or mark is not an element of l, or e == mark, the list is not modified.
	// The element and mark must not be nil.
	MoveAfter(e, mark *Element)
	// Remove removes e from l if e is an element of list l.
	// It returns the element value e.Value.
	// The element must not be nil.
	Remove(e *Element) interface{}
	// Truncate trancate deque, keeping the first size elements
	Truncate(keeping int)
	// Drain removes the specified range in the deque, returns drained
	Drain(from, to int) Deque
}

Deque deque

func New

func New() Deque

New returns an initialized Deque.

type Element

type Element struct {

	// The value stored with this element.
	Value interface{}
	// contains filtered or unexported fields
}

Element is an Element of a linked Deque.

func (*Element) Next

func (e *Element) Next() *Element

Next returns the next Deque element or nil.

func (*Element) Prev

func (e *Element) Prev() *Element

Prev returns the previous Deque element or nil.

Jump to

Keyboard shortcuts

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