上QQ阅读APP看书,第一时间看更新
The IterateList method
The IterateList method of the LinkedList class iterates from the headNode property and prints the property of the current head node. The iteration happens with the head node moves to nextNode of the headNode property until the current node is no longer equal to nil. The following code shows the IterateList method of the LinkedList class:
//IterateList method iterates over LinkedList
func (linkedList *LinkedList) IterateList() {
var node *Node
for node = linkedList.headNode; node != nil; node = node.nextNode {
fmt.Println(node.property)
}
}