(Changed in version 2.8.0) collect
has changed. The previous behavior can be reproduced with toSeq
.
使用 invariant: 开头部分没有 empty 的 iterator
使用 invariant: 开头部分没有 empty 的 iterator
维护 invariant: queue 中不能有 empty 的 iterator
维护 invariant: queue 中不能有 empty 的 iterator
以 BFS 遍历 DOM
1. 保存 Iterator ,以 lazy 的方式提高性能 2. 考虑到 scala.collection.immutable.Queue 的性能可能不如 ArrayDeque ,故采用 ArrayDeque