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

Function preorder

publication/code/chapter08/bst.rs:319–328  ·  view source on GitHub ↗

前中后层序遍历: 外部实现

(bst: Link<T,U>)

Source from the content-addressed store, hash-verified

317
318// 前中后层序遍历: 外部实现
319fn preorder<T, U>(bst: Link<T,U>)
320where T: Copy + Ord + Debug,
321 U: Copy + Debug
322{
323 if !bst.is_none() {
324 println!("key: {:?}, val: {:?}", bst.as_ref().unwrap().key.unwrap(), bst.as_ref().unwrap().val.unwrap());
325 preorder(bst.as_ref().unwrap().get_left());
326 preorder(bst.as_ref().unwrap().get_right());
327 }
328}
329
330fn inorder<T, U>(bst: Link<T,U>)
331where T: Copy + Ord + Debug,

Callers 1

orderFunction · 0.70

Calls 2

get_leftMethod · 0.45
get_rightMethod · 0.45

Tested by

no test coverage detected