MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / preorder

Function preorder

publication/code/chapter08/binary_tree.rs:290–296  ·  view source on GitHub ↗

前中后层序遍历: 外部实现 [递归方式], 考虑 bt 是不是该用 &Link

(bt: Link<T>)

Source from the content-addressed store, hash-verified

288// 前中后层序遍历: 外部实现 [递归方式],
289// 考虑 bt 是不是该用 &Link<T>
290fn preorder<T: Clone + Ord + ToString + Debug>(bt: Link<T>) {
291 if !bt.is_none() {
292 println!("key: {:?}", bt.as_ref().unwrap().get_key());
293 preorder(bt.as_ref().unwrap().get_left());
294 preorder(bt.as_ref().unwrap().get_right());
295 }
296}
297
298fn inorder<T: Clone + Ord + ToString + Debug>(bt: Link<T>) {
299 if !bt.is_none() {

Callers 1

orderFunction · 0.70

Calls 2

get_leftMethod · 0.45
get_rightMethod · 0.45

Tested by

no test coverage detected