March 2019
Intermediate to advanced
336 pages
9h 9m
English
The String method turns the tree into a string format. At first, the Lock() method is invoked on the tree lock instance. Then, the Unlock() method of the tree lock instance is deferred. The String method prints a visual representation of tree:
// String methodfunc (tree *BinarySearchTree) String() { tree.lock.Lock() defer tree.lock.Unlock() fmt.Println("------------------------------------------------") stringify(tree.rootNode, 0) fmt.Println("------------------------------------------------")}
Read now
Unlock full access