Documentation
¶
Overview ¶
Package doublylinkedlist is a implementation for doubly linked list data structure in go language
Index ¶
- type DoublyLinkedList
- func (list *DoublyLinkedList) DeleteAt(position int) (int, error)
- func (list *DoublyLinkedList) DeleteEnd() (int, error)
- func (list *DoublyLinkedList) DeleteStart() (int, error)
- func (list *DoublyLinkedList) Head() *Node
- func (list *DoublyLinkedList) InsertAt(node *Node, position int) error
- func (list *DoublyLinkedList) InsertEnd(node *Node)
- func (list *DoublyLinkedList) InsertStart(node *Node)
- func (list *DoublyLinkedList) Lenght() int
- func (list *DoublyLinkedList) PrintList()
- func (list *DoublyLinkedList) Tail() *Node
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DoublyLinkedList ¶
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