linkedlist

package
v0.0.0-...-e90a610 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IList

type IList interface {
	// read operations
	Len() int
	Front() *Node
	Back() *Node

	// write operations
	PushFront(*Node)
	PushBack(*Node)
	InsertBefore(n, target *Node)
	InsertAfter(n, target *Node)

	// delete operation
	Remove(*Node)

	// advance operations
	Reverse()
}

IList defines the linked list interface

type List

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

func New

func New() *List

New returns an initialized doubly linked list.

func (*List) Back

func (l *List) Back() *Node

func (*List) Front

func (l *List) Front() *Node

func (*List) Init

func (l *List) Init() *List

Init -

func (*List) InsertAfter

func (l *List) InsertAfter(n, target *Node)

func (*List) InsertBefore

func (l *List) InsertBefore(n, target *Node)

func (*List) PushBack

func (l *List) PushBack(n *Node)

func (*List) PushFront

func (l *List) PushFront(n *Node)

func (*List) Reverse

func (l *List) Reverse()

type ListD

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

ListD defines a doubly linked list n <---> ... <--> n

func NewD

func NewD() *ListD

NewD returns an initialized doubly linked list.

func (*ListD) Back

func (l *ListD) Back() *NodeD

func (*ListD) Front

func (l *ListD) Front() *NodeD

func (*ListD) Init

func (l *ListD) Init() *ListD

Init -

func (*ListD) InsertAfter

func (l *ListD) InsertAfter(n, target *NodeD)

InsertAfter inserts the node after target

func (*ListD) InsertBefore

func (l *ListD) InsertBefore(n, target *NodeD)

InsertBefore inserts the node before target

func (*ListD) Len

func (l *ListD) Len() int

func (*ListD) PushBack

func (l *ListD) PushBack(n *NodeD)

PushBack inserts the node after tail

func (*ListD) PushFront

func (l *ListD) PushFront(n *NodeD)

PushFront inserts the node before head

func (*ListD) Remove

func (l *ListD) Remove(n *NodeD)

Remove deletes the node

func (*ListD) Reverse

func (l *ListD) Reverse()

Reverse reverse the list

type ListDR

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

ListDR defines a doubly linked list implemented using ring

|-------------------------|

root <--> n <---> ... <--> n

func NewDR

func NewDR() *ListDR

NewDR returns an initialized doubly linked ring.

func (*ListDR) Back

func (l *ListDR) Back() *NodeDR

func (*ListDR) Front

func (l *ListDR) Front() *NodeDR

func (*ListDR) Init

func (l *ListDR) Init() *ListDR

func (*ListDR) InsertAfter

func (l *ListDR) InsertAfter(n, target *NodeDR)

InsertAfter inserts the node after target

|-n_new-|
|       |

... n <---> n_target <-x-> n <---> ...

func (*ListDR) InsertBefore

func (l *ListDR) InsertBefore(n, target *NodeDR)

InsertBefore inserts the node before target

|-n_new-|
|       |

... n <---> n <-x-> n_target <---> ...

func (*ListDR) Len

func (l *ListDR) Len() int

func (*ListDR) PushBack

func (l *ListDR) PushBack(n *NodeDR)

PushBack inserts the node before root

	|-----------------------------|
 |---------x----------|		  |

root <---> ... <---> n <---> n_new

func (*ListDR) PushFront

func (l *ListDR) PushFront(n *NodeDR)

PushFront inserts the node after root root <-x-> n <---> n <---> ...

|        |
|-n_new-|

func (*ListDR) Remove

func (l *ListDR) Remove(n *NodeDR)

Remove deletes the node

|---------------|
|               |

... n <-x-> n <-x-> n ...

func (*ListDR) Reverse

func (l *ListDR) Reverse()

Reverse reverse the list

type Node

type Node struct {
	Data interface{}
	// contains filtered or unexported fields
}

Node defines the node in a linked list

func (*Node) Next

func (n *Node) Next() *Node

type NodeD

type NodeD struct {
	Data interface{}
	// contains filtered or unexported fields
}

NodeD defines the node in a doubly linked list

func (*NodeD) Next

func (n *NodeD) Next() *NodeD

func (*NodeD) Prev

func (n *NodeD) Prev() *NodeD

type NodeDR

type NodeDR struct {
	Data interface{}
	// contains filtered or unexported fields
}

NodeDR defines the node in a doubly linked list

func (*NodeDR) Next

func (n *NodeDR) Next() *NodeDR

func (*NodeDR) Prev

func (n *NodeDR) Prev() *NodeDR

Jump to

Keyboard shortcuts

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