s******e 发帖数: 108 | 1 Design an iterator for a collection of collections. The iterator should hide
the nesting, allowing you to iterate all of the elements belonging to all
of the collections as if you were working with a single collection.
For Example:
a={{1,2,3},4,{},{5,6,{7,{},{8}}},}.
The result of calling 8 time next() should be:
1,2,3,4,5,6,7,8. | c****p 发帖数: 6474 | 2 看着像DFS
hide
【在 s******e 的大作中提到】 : Design an iterator for a collection of collections. The iterator should hide : the nesting, allowing you to iterate all of the elements belonging to all : of the collections as if you were working with a single collection. : For Example: : a={{1,2,3},4,{},{5,6,{7,{},{8}}},}. : The result of calling 8 time next() should be: : 1,2,3,4,5,6,7,8.
| d********t 发帖数: 9628 | 3 为啥要那么复杂?如果a是array的话直接next就好了
【在 c****p 的大作中提到】 : 看着像DFS : : hide
| B*******1 发帖数: 2454 | 4 是不是用一个iterator,里面根据每个collection的类型再call相应对象的iterator去
打印出数。 | A**u 发帖数: 2458 | |
|