Learn Data Structures and Algorithms with Golang
上QQ阅读APP看书,第一时间看更新

The LinkedList class

The LinkedList class has the headNode pointer as its property. By traversing to nextNode from headNode, you can iterate through the linked list, as shown in the following code:

// LinkedList class
type LinkedList struct {
headNode *Node
}

The different methods of the LinkedList class, such as AddtoHead, IterateList, LastNode, AddtoEnd, NodeWithValue, AddAfter, and the main method, are discussed in the following sections.