March 2020
Intermediate to advanced
406 pages
8h 39m
English
A forward list is an implementation of a singly linked list. A singly linked list typically has a smaller memory footprint than a doubly linked list; however, iteration through a singly linked list isn't as good, particularly in the reverse direction. Let's see how to implement a forward list:
package mainimport "fmt"type SinglyLinkedList struct { head *LinkedListNode}type LinkedListNode struct { data string next *LinkedListNode}
func (ll *SinglyLinkedList) Append(node *LinkedListNode) { if ll.head == nil { ll.head = node return } currentNode := ll.head for currentNode.next != nil { currentNode ...Read now
Unlock full access