Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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)?

share|improve this question

closed as off-topic by gnat, GlenH7, MichaelT, Snowman, Ampt Aug 28 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, MichaelT, Ampt
If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers 3

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.

share|improve this answer
Thanks, since asking this question I've bought your book, but am only at chapter 3. –  Matthew Finlay Jun 15 '13 at 6:31

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

share|improve this answer

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.

share|improve this answer

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