March 2019
Intermediate to advanced
336 pages
9h 9m
English
The PreOrderTraverseTree method of the BinarySearchTree class takes the function as its parameter. The Lock method on the tree's lock instance is invoked first, and the Unlock method is deferred. The PreOrderTraverseTree method is called with the rootNode of the tree and function as parameters:
// PreOrderTraverse methodfunc (tree *BinarySearchTree) PreOrderTraverseTree(function func(int)) { tree.lock.Lock() defer tree.lock.Unlock() preOrderTraverseTree(tree.rootNode, function)}
Read now
Unlock full access