I frequently would like to iterate over a view of some underlying data structure, e.g. a backwards iteration or only a slice of a list. The Java standard library has some support for multiple iterator views, e.g. with Map#keySet and Map#elemSet. I would like an API to quickly generate such views:
List<A> myList;
for (A it : iter(myList).from(24).backwards()) {
...
}
I would like an easy way to define these views ideally without being significantly slower than normal iterators.
List.subList(...)has existed since the introduction of the Collections Framework in Java 1.2.