lists

package module
v0.0.0-...-4ed79f2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: JSON Imports: 5 Imported by: 0

README

== About ==

Lists provide several implementations of classic linked-list data structures. Currently the following datatypes
are provided:

LinearList is a standard singly-linked list without any protections to guard against cyclic links between nodes;

CycList is a generalised circular list where the terminating node links back to the first node.

Both CycList and LinearList use a common ListHeader allowing them to be interchanged as necessary. This ListHeader
has a chain.Node type associated with it which specifies the type of node used by a given instance of a list, and
provides access caching to speed operations in frequently accessed portions of the list.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CycList

type CycList struct {
	ListHeader
}

func Loop

func Loop(items ...interface{}) (c *CycList)

A declarative method for building CycLists

func NewCycList

func NewCycList(n chain.Node) *CycList

func (*CycList) Append

func (c *CycList) Append(v interface{})

func (CycList) At

func (c CycList) At(i int) interface{}

Return the value stored at the given offset from the start of the list

func (CycList) Clone

func (c CycList) Clone() (r *CycList)

func (*CycList) Concatenate

func (c *CycList) Concatenate(i interface{})

func (CycList) Cycle

func (c CycList) Cycle(f func(interface{}))

Iterate over all elements of the list indefinitely The only way to terminate iteration is by raising a panic() in the applied function

func (CycList) Equal

func (c CycList) Equal(o interface{}) (r bool)

Determines if another object is equivalent to the CycList Two CycLists are identical if they both have the same number of nodes, and the head of each node is the same

func (*CycList) Reverse

func (c *CycList) Reverse()

Reverses the order in which elements of a CycList are traversed

func (*CycList) Rotate

func (c *CycList) Rotate(i int)

func (CycList) Set

func (c CycList) Set(i int, v interface{})

Set the value stored at the given offset from the start of the list

func (*CycList) Tail

func (c *CycList) Tail()

type Equatable

type Equatable interface {
	chain.Equatable
}

type Flattenable

type Flattenable interface {
	Flatten()
}

type Iterable

type Iterable interface {
	Each(func(interface{}))
}

type Linear

type Linear interface {
	Len() int
}

type LinearList

type LinearList struct {
	ListHeader
}

func List

func List(items ...interface{}) (l *LinearList)

func NewLinearList

func NewLinearList(n chain.Node) *LinearList

func (*LinearList) Absorb

func (l *LinearList) Absorb(i int, o *LinearList) (ok bool)

Take all the elements from another list and insert them into this list, destroying the other list if successful.

func (LinearList) Clone

func (l LinearList) Clone() *LinearList

func (*LinearList) Cut

func (l *LinearList) Cut(start, end int) (r LinearList)

Removes the elements in the range from the current list and returns a new list containing them.

func (*LinearList) Delete

func (l *LinearList) Delete(from, to int)

Removes all elements in the range from the list.

func (LinearList) End

func (l LinearList) End() chain.Node

func (LinearList) Equal

func (l LinearList) Equal(o interface{}) (r bool)

Determines if another object is equivalent to the LinearList Two LinearLists are identical if they both have the same number of nodes, and the head of each node is the same

func (*LinearList) Insert

func (l *LinearList) Insert(i int, o interface{})

Insert an item into the list at the given location.

type Linkable

type Linkable interface {
	Linear
	Start() chain.Node
	End() chain.Node
}

type ListHeader

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

func NewListHeader

func NewListHeader(n chain.Node) ListHeader

func (*ListHeader) Append

func (l *ListHeader) Append(v interface{})

func (ListHeader) At

func (l ListHeader) At(i int) (r interface{})

func (ListHeader) Clear

func (l ListHeader) Clear(i int)

func (ListHeader) Clone

func (l ListHeader) Clone() (r *ListHeader)

func (ListHeader) Compact

func (l ListHeader) Compact() []interface{}

func (*ListHeader) Concatenate

func (l *ListHeader) Concatenate(s interface{})

func (ListHeader) Each

func (l ListHeader) Each(f func(interface{}))

func (ListHeader) End

func (l ListHeader) End() chain.Node

func (ListHeader) EnforceBounds

func (l ListHeader) EnforceBounds(start, end *int) (ok bool)

func (ListHeader) Equal

func (l ListHeader) Equal(o interface{}) (r bool)

func (*ListHeader) Erase

func (l *ListHeader) Erase()

func (*ListHeader) Expand

func (l *ListHeader) Expand(i, n int)

func (*ListHeader) Flatten

func (l *ListHeader) Flatten()

Iterates through the list reducing the nesting of each element which can be flattened. Elements which are themselves LinearLists will be inlined as part of the containing list and their contained list destroyed.

func (ListHeader) Head

func (l ListHeader) Head() (r interface{})

func (ListHeader) Len

func (l ListHeader) Len() (c int)

func (ListHeader) NewListNode

func (l ListHeader) NewListNode(value interface{}) (n chain.Node)

func (*ListHeader) Reverse

func (l *ListHeader) Reverse()

Reverses the order in which elements of a List are traversed

func (ListHeader) Set

func (l ListHeader) Set(i int, v interface{})

func (ListHeader) Start

func (l ListHeader) Start() chain.Node

func (ListHeader) String

func (l ListHeader) String() (t string)

func (*ListHeader) Tail

func (l *ListHeader) Tail()

type Sequence

type Sequence interface {
	Linear
	Iterable
	At(int) interface{}
	Set(int, interface{})
}

Jump to

Keyboard shortcuts

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