迭代函数,包括 mut 版本
(&self)
| 497 | |
| 498 | // 迭代函数,包括 mut 版本 |
| 499 | fn iter<'a>(&self) -> Iter<'a, K, V> { |
| 500 | let mut iterator = Iter { stack: Vec::new() }; |
| 501 | let mut node = self.root; |
| 502 | unsafe { |
| 503 | while !node.is_null() { |
| 504 | iterator.stack.push(&*node); |
| 505 | node = (*node).left; |
| 506 | } |
| 507 | } |
| 508 | iterator |
| 509 | } |
| 510 | |
| 511 | fn iter_mut<'a>(&mut self) -> IterMut<'a, K, V> { |
| 512 | let mut iterator = IterMut { stack: Vec::new() }; |