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

Function basic

publication/code/chapter08/bst.rs:382–402  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

380 order();
381
382 fn basic() {
383 let mut bst = BST::<i32, char>::new();
384 bst.insert(8, 'e'); bst.insert(6,'c');
385 bst.insert(7, 'd'); bst.insert(5,'b');
386 bst.insert(10,'g'); bst.insert(9,'f');
387 bst.insert(11,'h'); bst.insert(4,'a');
388
389 println!("bst is empty: {}", bst.is_empty());
390 println!("bst size: {}", bst.size());
391 println!("bst leaves: {}", bst.leaf_size());
392 println!("bst internals: {}", bst.none_leaf_size());
393 println!("bst depth: {}", bst.depth());
394
395 let min_kv = bst.min();
396 let max_kv = bst.max();
397 println!("min key: {:?}, min val: {:?}", min_kv.0, min_kv.1);
398 println!("max key: {:?}, max val: {:?}", max_kv.0, max_kv.1);
399
400 println!("bst contains 5: {}", bst.contains(&5));
401 println!("key: 5, val: {:?}", bst.get(&5).unwrap());
402 }
403
404 fn order() {
405 let mut bst = BST::<i32, char>::new();

Callers 1

mainFunction · 0.70

Calls 3

insertMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected