Many languages use the concept of an iterator. The c++ STL expands on this with input iterators, output iterators, forward, bidirectional, random access and others. As far as I know, these distinctions don't exist in other languages. In this talk the author of the STL, Alexander Stepanov, talks about iterators (among other things), and mentions the idea and of 2-dimensional iterators. I haven't seen these anywhere.

Question 1: Are there other languages/ libraries that expand on iterators and/or use 2-dimensional iterators?

Question 2: Could anyone point me to some good resources on iterator theory (if that is what it's called)?

closed as off-topic by gnat, user53019, user40980, user22815, Ampt Aug 28 '14 at 15:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, Community, Ampt
If this question can be reworded to fit the rules in the help center, please edit the question.


Re question 2: see chapter 6 (Iterators) of Elements of Programming by Alexander Stepanov (the author of STL) and Paul McJones (me) for the theory of iterators. Re question 1: see chapters 7 (Coordinate Structures) and 8 (Coordinates with Mutable Successors) of the same book for some generalizations of iterators to data structures with more complex shapes than immutable linear shapes.

  • 1
    Thanks, since asking this question I've bought your book, but am only at chapter 3. – Matthew Finlay Jun 15 '13 at 6:31
  • its a beautiful book, but since buying it i had to read over 10 (not joking) others books any many articles + youtube videos to understand what this book is trying to say )) no regrets, though – c69 Oct 11 '18 at 5:57

Well, Java's ListIterator is bidirectional. In general I am not sure how much linguistic support is needed for iterators. Some syntactic sugar sometimes helps (see Scala's for loop for the most advanced I know of off hand).

As to iterator theory, I'm pretty sure ever iterator is itself a data structure, or is backed by one. Therefore I'd wager there is no "iterator theory", the study of data structures covers it.

The data structure I can think of that generalizes iteration the most is http://en.wikipedia.org/wiki/Zipper_%28data_structure%29


You may be interested in D's ranges. They are supposed to be based on STL iterators only cleaned up and easier to use. Here is a pretty good article on them. It even suggests higher order ranges though I don't know if those actually get used in D.

Not the answer you're looking for? Browse other questions tagged or ask your own question.