scala迭代器原理图
2021-09-08 11:54:15 1 举报
登录查看完整内容
scala迭代器原理图,多个迭代器的执行流程
作者其他创作
大纲/内容
1.2
集合数据
第二个迭代器iterFlatMap = iter.flatMap(fun)fun函数会返回集合
1.1
collect.iterator
取值
cur赋值
第三个迭代器iterMap = iterFlatMap.map(fun)fun是映射函数
第一个迭代器iter = collect.iterator
cur没有值时
hasNext = 父.hasNext
next()
hasNext
1
如果cur有值 : true
hasNext = !these.isEmpty
next() = these.head or 抛异常
fun函数
next() = fun(父.next())
hasNext
cur 函数返回的集合迭代化cur = 函数.toIterator
next() = cur.next() 或抛异常
收藏
0 条评论
回复 删除
下一页