doublylinkedlist

package
v0.0.0-...-73e22f4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package doublylinkedlist is a implementation for doubly linked list data structure in go language

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoublyLinkedList

type DoublyLinkedList struct {
	Len   int
	Start *Node
	End   *Node
}

DoublyLinkedList struct contains lenght of doubly linked list, address of first node and address of last node

func NewDoublyLinkedList

func NewDoublyLinkedList() DoublyLinkedList

NewDoublyLinkedList creates new empty linked list

func (*DoublyLinkedList) DeleteAt

func (list *DoublyLinkedList) DeleteAt(position int) (int, error)

DeleteAt removes specified node from doubly linked list and returns data. Returns error, if position is invalid.

func (*DoublyLinkedList) DeleteEnd

func (list *DoublyLinkedList) DeleteEnd() (int, error)

DeleteEnd removes last doubly linked list node and returns data. Returns error, if linkedlist is empty.

func (*DoublyLinkedList) DeleteStart

func (list *DoublyLinkedList) DeleteStart() (int, error)

DeleteStart removes first doubly linked list node and returns data. Returns error, if linkedlist is empty.

func (*DoublyLinkedList) Head

func (list *DoublyLinkedList) Head() *Node

Head returns the first doubly linked list node

func (*DoublyLinkedList) InsertAt

func (list *DoublyLinkedList) InsertAt(node *Node, position int) error

InsertAt inserts node at specified position in doubly linked list

func (*DoublyLinkedList) InsertEnd

func (list *DoublyLinkedList) InsertEnd(node *Node)

InsertEnd inserts node at the end of doubly linked list

func (*DoublyLinkedList) InsertStart

func (list *DoublyLinkedList) InsertStart(node *Node)

InsertStart inserts node at the start of doubly linked list

func (*DoublyLinkedList) Lenght

func (list *DoublyLinkedList) Lenght() int

Lenght returns the number of node currently present in doubly linked list

func (*DoublyLinkedList) PrintList

func (list *DoublyLinkedList) PrintList()

PrintList prints entire doubly linked list without changing underlying data.

func (*DoublyLinkedList) Tail

func (list *DoublyLinkedList) Tail() *Node

Tail returns the last doubly linked list node

type Node

type Node struct {
	Data int
	Prev *Node
	Next *Node
}

Node struct contains actual data and address to next node

func NewNode

func NewNode(data int) *Node

NewNode creates a new Node with integer data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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