【发布时间】:2008-12-16 11:16:22
【问题描述】:
在 Java 中获取一系列整数的迭代器的最短方法是什么?换句话说,实现以下内容:
/**
* Returns an Iterator over the integers from first to first+count.
*/
Iterator<Integer> iterator(Integer first, Integer count);
类似
(first..first+count).iterator()
【问题讨论】:
-
有什么理由不能以经典方式“加 1”吗?只是感兴趣
-
这是一个框架,需要我写一个迭代器
-
清晰胜过简洁,并且有许多 Range 类可用,包括迭代。