(value interface{})
| 17 | } |
| 18 | |
| 19 | func (tree *BinaryTree) Search(value interface{}) *BinaryTree { |
| 20 | if tree.node == nil { |
| 21 | return nil |
| 22 | } |
| 23 | |
| 24 | if tree.node == value { |
| 25 | return tree |
| 26 | } |
| 27 | if tree.lessFun(value, tree.node) { |
| 28 | return tree.left.Search(value) |
| 29 | } else { |
| 30 | return tree.right.Search(value) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | func (tree *BinaryTree) Insert(value interface{}) { |
| 35 | if tree.node == nil { |
no outgoing calls