list

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deque

type Deque[E any] interface {
	// Len returns the number of elements of Deque.
	// The complexity is O(1).
	Len() int
	// Clear clears Deque
	Clear()
	// Iter call fn on all elements which after the offset, stopped if false returned
	Iter(offset int, fn func(E) bool)
	// Front returns the first element of Deque, false if the list is empty.
	Front() (*Element[E], bool)
	// PopFront removes and returns the first element of Deque
	PopFront() *Element[E]
	// Front returns the first element of Deque, panic if the list is empty.
	MustFront() *Element[E]
	// Back returns the last element of Deque, false if the list is empty.
	Back() (*Element[E], bool)
	// PopBack removes and returns the last element of Deque
	PopBack() *Element[E]
	// MustBack returns the last element of Deque, panic if the list is empty.
	MustBack() *Element[E]
	// PushFront inserts a new element e with value v at the front of deque.
	PushFront(v E) *Element[E]
	// PushBack inserts a new element e with value v at the back of deque.
	PushBack(v E) *Element[E]
	// 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 E, mark *Element[E]) *Element[E]
	// 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 E, mark *Element[E]) *Element[E]
	// 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[E])
	// 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[E])
	// 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[E])
	// 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[E])
	// 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[E]) E
	// 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[E]
}

Deque deque

func New

func New[E any]() Deque[E]

New returns an initialized Deque.

type Element

type Element[E any] struct {

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

Element is an Element of a linked Deque.

func (*Element[E]) Next

func (e *Element[E]) Next() *Element[E]

Next returns the next Deque element or nil.

func (*Element[E]) Prev

func (e *Element[E]) Prev() *Element[E]

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