Method
CreateChild
(value NodeValue, id int)
Source from the content-addressed store, hash-verified
| 25 | } |
| 26 | |
| 27 | func (n *Edge) CreateChild(value NodeValue, id int) Node { |
| 28 | // When the left child is nil, it's a left edge |
| 29 | if n.NodeLeft == nil { |
| 30 | return &Edge{ |
| 31 | ID: id, |
| 32 | NodeValue: value, |
| 33 | Parent: n, |
| 34 | NodeLeft: nil, |
| 35 | NodeRight: nil, |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // When the left child is a leaf, it's a right edge |
| 40 | if n.NodeLeft.Kind() == "leaf" { |
| 41 | return &Edge{ |
| 42 | ID: id, |
| 43 | NodeValue: value, |
| 44 | Parent: n, |
| 45 | NodeLeft: nil, |
| 46 | NodeRight: nil, |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return &Leaf{ |
| 51 | ID: id, |
| 52 | NodeValue: value, |
| 53 | Parent: n, |
| 54 | NodeLeft: nil, |
| 55 | NodeRight: nil, |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func (n *Edge) GetID() int { |
| 60 | return n.ID |
Callers
nothing calls this directly
Tested by
no test coverage detected