ilist

package
v0.0.0-...-23e6066 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package ilist provides the implementation of intrusive linked lists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

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

Entry is a default implementation of Linker. Users can add anonymous fields of this type to their structs to make them automatically implement the methods needed by List.

func (*Entry) Next

func (e *Entry) Next() Linker

Next returns the entry that follows e in the list.

func (*Entry) Prev

func (e *Entry) Prev() Linker

Prev returns the entry that precedes e in the list.

func (*Entry) SetNext

func (e *Entry) SetNext(entry Linker)

SetNext assigns 'entry' as the entry that follows e in the list.

func (*Entry) SetPrev

func (e *Entry) SetPrev(entry Linker)

SetPrev assigns 'entry' as the entry that precedes e in the list.

type Linker

type Linker interface {
	Next() Linker
	Prev() Linker
	SetNext(Linker)
	SetPrev(Linker)
}

Linker is the interface that objects must implement if they want to be added to and/or removed from List objects.

N.B. When substituted in a template instantiation, Linker doesn't need to be an interface, and in most cases won't be.

type List

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

List is an intrusive list. Entries can be added to or removed from the list in O(1) time and with no additional memory allocations.

The zero value for List is an empty list ready to use.

To iterate over a list (where l is a List):

     for e := l.Front(); e != nil; e = e.Next() {
		// do something with e.
     }

func (*List) Back

func (l *List) Back() Linker

Back returns the last element of list l or nil.

func (*List) Empty

func (l *List) Empty() bool

Empty returns true iff the list is empty.

func (*List) Front

func (l *List) Front() Linker

Front returns the first element of list l or nil.

func (*List) InsertAfter

func (l *List) InsertAfter(b, e Linker)

InsertAfter inserts e after b.

func (*List) InsertBefore

func (l *List) InsertBefore(a, e Linker)

InsertBefore inserts e before a.

func (*List) PushBack

func (l *List) PushBack(e Linker)

PushBack inserts the element e at the back of list l.

func (*List) PushBackList

func (l *List) PushBackList(m *List)

PushBackList inserts list m at the end of list l, emptying m.

func (*List) PushFront

func (l *List) PushFront(e Linker)

PushFront inserts the element e at the front of list l.

func (*List) Remove

func (l *List) Remove(e Linker)

Remove removes e from l.

func (*List) Reset

func (l *List) Reset()

Reset resets list l to the empty state.

Jump to

Keyboard shortcuts

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