dll

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package dll provides a lock-free implementation of doubly linked list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 list.

type List

type List struct {
	// contains filtered or unexported fields
}

List represents a doubly linked list.

func New

func New() *List

New returns an initialized list.

func (*List) Empty

func (l *List) Empty() bool

Empty returns true if list l is empty, false otherwise

func (*List) Init

func (l *List) Init() *List

Init initializes or clears list l.

func (*List) Next

func (l *List) Next(node *Element) *Element

Next returns the next list element or nil.

func (*List) PopLeft

func (l *List) PopLeft() interface{}

PopLeft returns the first element of list l or nil if the list is empty.

func (*List) PopRight

func (l *List) PopRight() interface{}

PopRight returns the last element of list l or nil if the list is empty.

func (*List) Prev

func (l *List) Prev(node *Element) *Element

Prev returns the previous list element or nil.

func (*List) PushLeft

func (l *List) PushLeft(v interface{}) *Element

PushLeft inserts a new element e with value v at the front of list l and returns e.

func (*List) PushRight

func (l *List) PushRight(v interface{}) *Element

PushRight inserts a new element e with value v at the back of list l and returns e.

func (*List) Remove

func (l *List) Remove(e *Element) interface{}

Remove removes e from l if e is an element of list l. It returns the element value e.Value if succeed, nil otherwise

Jump to

Keyboard shortcuts

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