March 2019
Intermediate to advanced
336 pages
9h 9m
English
The RemoveNode method of the BinarySearchTree class removes the element with key that's passed in. The method takes the key integer value as the parameter. The Lock() method is invoked on the tree's lock instance first. The Unlock() method of the tree lock instance is deferred, and removeNode is called with rootNode and the key value as parameters, as shown here:
// RemoveNode methodfunc (tree *BinarySearchTree) RemoveNode(key int) { tree.lock.Lock() defer tree.lock.Unlock() removeNode(tree.rootNode, key)}
Read now
Unlock full access