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

Method insert

publication/code/chapter09/bfs.rs:59–69  ·  view source on GitHub ↗

插入节点,RefCell 使用 borrow_mut 修改

(&mut self, data: usize)

Source from the content-addressed store, hash-verified

57
58 // 插入节点,RefCell 使用 borrow_mut 修改
59 fn insert(&mut self, data: usize) {
60 let node = Rc::new(RefCell::new(Node::new(data)));
61
62 if self.is_empty() {
63 self.first = Some(node.clone());
64 self.last = Some(node);
65 } else {
66 self.last.as_mut().unwrap().borrow_mut().next = Some(node.clone());
67 self.last = Some(node);
68 }
69 }
70}
71
72// 根据 data 构建图

Callers 15

bucket_sortFunction · 0.45
mainFunction · 0.45
enqueueMethod · 0.45
add_vertexMethod · 0.45
add_edgeMethod · 0.45
enqueueMethod · 0.45
add_vertexMethod · 0.45
build_word_graphFunction · 0.45
add_vertexMethod · 0.45
add_edgeMethod · 0.45
add_vertexMethod · 0.45
add_edgeMethod · 0.45

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected