linkedlist

package
v0.8.0-vendored Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: MIT Imports: 1 Imported by: 0

README

Usage

This is the Go standard library implementation of a linked list (https://golang.org/src/container/list/list.go), modified such that genny (https://github.com/cheekybits/genny) can be used to generate a typed linked list.

To generate, run

genny -pkg $PACKAGE -in linkedlist.go -out $OUTFILE gen Item=$TYPE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item generic.Type

Item is a generic type.

type ItemElement

type ItemElement struct {

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

ItemElement is an element of a linked list.

func (*ItemElement) Next

func (e *ItemElement) Next() *ItemElement

Next returns the next list element or nil.

func (*ItemElement) Prev

func (e *ItemElement) Prev() *ItemElement

Prev returns the previous list element or nil.

type ItemList

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

ItemList is a linked list of Items.

func NewItemList

func NewItemList() *ItemList

NewItemList returns an initialized list.

func (*ItemList) Back

func (l *ItemList) Back() *ItemElement

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

func (*ItemList) Front

func (l *ItemList) Front() *ItemElement

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

func (*ItemList) Init

func (l *ItemList) Init() *ItemList

Init initializes or clears list l.

func (*ItemList) InsertAfter

func (l *ItemList) InsertAfter(v Item, mark *ItemElement) *ItemElement

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.

func (*ItemList) InsertBefore

func (l *ItemList) InsertBefore(v Item, mark *ItemElement) *ItemElement

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.

func (*ItemList) Len

func (l *ItemList) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*ItemList) MoveAfter

func (l *ItemList) MoveAfter(e, mark *ItemElement)

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.

func (*ItemList) MoveBefore

func (l *ItemList) MoveBefore(e, mark *ItemElement)

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.

func (*ItemList) MoveToBack

func (l *ItemList) MoveToBack(e *ItemElement)

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.

func (*ItemList) MoveToFront

func (l *ItemList) MoveToFront(e *ItemElement)

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.

func (*ItemList) PushBack

func (l *ItemList) PushBack(v Item) *ItemElement

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

func (*ItemList) PushBackList

func (l *ItemList) PushBackList(other *ItemList)

PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same. They must not be nil.

func (*ItemList) PushFront

func (l *ItemList) PushFront(v Item) *ItemElement

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

func (*ItemList) PushFrontList

func (l *ItemList) PushFrontList(other *ItemList)

PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same. They must not be nil.

func (*ItemList) Remove

func (l *ItemList) Remove(e *ItemElement) Item

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.

Jump to

Keyboard shortcuts

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