Em Qui, 2009-01-08 às 13:42 +1100, Timothy S. Nelson escreveu: > On Wed, 7 Jan 2009, Jon Lang wrote: > > How would I define the method for writing to an iterator? > I guess I'd assumed that writing to an iterator wouldn't be possible, > as there are kinds of iterators where writing to them makes no sense; I'd > assumed that if you wanted to write to something you'd use a list. Other > than > as an interesting exercise, I don't see the point of using an iterator for > this purpose (there may *be* uses, but I don't see them).
There is at least one use: Some databases (berkeley db comes to my mind) allow you to perform inserts using a cursor (which would be an iterator in this case). The Java API also provides a insert mechanism... Although in some cases, the update API will be specific to the object you're dealing with, it can just be a regular object which happens to implement the Iterator role... daniel