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

Method size

publication/code/chapter08/avl.rs:80–85  ·  view source on GitHub ↗

计算树节点数: 左右子树节点 + 根节点数,递归计算

(&self)

Source from the content-addressed store, hash-verified

78
79 // 计算树节点数: 左右子树节点 + 根节点数,递归计算
80 fn size(&self) -> usize {
81 match self {
82 Null => 0,
83 Tree(n) => 1 + n.left.size() + n.right.size(),
84 }
85 }
86
87 // 计算叶节点数
88 fn leaf_size(&self) -> usize {

Callers 3

none_leaf_sizeMethod · 0.45
levelorderMethod · 0.45
levelorderFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected