March 2019
Intermediate to advanced
336 pages
9h 9m
English
The AddToEnd method adds the node to the end of the double linked list. The AddToEnd method of the LinkedList class creates a node whose property is set as the integer parameter property. The method sets the previousNode property of the node that was added with the current lastNode property as follows. The nextNode of the current lastNode property is set to a node added with property at the end as follows:
//AddToEnd method of LinkedListfunc (linkedList *LinkedList) AddToEnd(property int) { var node = &Node{} node.property = property node.nextNode = nil var lastNode *Node lastNode = linkedList.LastNode() if lastNode != nil { lastNode.nextNode = node node.previousNode = lastNode }}
The example output after the AddToEnd ...
Read now
Unlock full access