linkedlist

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DllNode

type DllNode struct {
	Vertex     *vertex.Vertex
	Prev, Next *DllNode
}

DllNode consists of the curr Vertex, Prev and Next DllNodes

type DoublyLinkedList

type DoublyLinkedList struct {
	Head, Tail *DllNode
}

DoublyLinkedList is the node of DLL which is connected to the tail and the head

func NewDoublyLinkedList

func NewDoublyLinkedList() *DoublyLinkedList

NewDoublyLinkedList returns DLL implementation

func (*DoublyLinkedList) InsertAfter

func (dll *DoublyLinkedList) InsertAfter(node, nodeToInsert *DllNode)

InsertAfter inserts node after the provided node

func (*DoublyLinkedList) InsertBefore

func (dll *DoublyLinkedList) InsertBefore(node, nodeToInsert *DllNode)

InsertBefore inserts node before the provided node

func (*DoublyLinkedList) Push

func (dll *DoublyLinkedList) Push(vertex *vertex.Vertex)

Push used to push vertex to the head

func (*DoublyLinkedList) PushTail

func (dll *DoublyLinkedList) PushTail(vertex *vertex.Vertex)

PushTail used to push vertex to the tail

func (*DoublyLinkedList) Remove

func (dll *DoublyLinkedList) Remove(node *DllNode)

Remove removes the node

func (*DoublyLinkedList) Reset

func (dll *DoublyLinkedList) Reset()

Reset resets the whole DLL

func (*DoublyLinkedList) SetHead

func (dll *DoublyLinkedList) SetHead(node *DllNode)

SetHead O(1) time + space

func (*DoublyLinkedList) SetTail

func (dll *DoublyLinkedList) SetTail(node *DllNode)

SetTail sets the tail, constant O(1) time and space

Jump to

Keyboard shortcuts

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