按照节点位置返回节点组成的字符串表达式: 内部实现
(&self)
| 263 | |
| 264 | // 按照节点位置返回节点组成的字符串表达式: 内部实现 |
| 265 | fn iexp(&self) -> String { |
| 266 | let mut exp = "".to_string(); |
| 267 | |
| 268 | exp += "("; |
| 269 | let exp_left = match &self.left { |
| 270 | Some(left) => left.iexp(), |
| 271 | None => "".to_string(), |
| 272 | }; |
| 273 | exp += &exp_left; |
| 274 | |
| 275 | exp += &self.get_key().to_string(); |
| 276 | |
| 277 | let exp_right = match &self.right { |
| 278 | Some(right) => right.iexp(), |
| 279 | None => "".to_string(), |
| 280 | }; |
| 281 | exp += &exp_right; |
| 282 | exp += ")"; |
| 283 | |
| 284 | exp |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | // 前中后层序遍历: 外部实现 [递归方式], |