Nice iterator naming [closed]
Closed 10 years ago.
Is there an idiom for a loop that executes some block of instructions between iterations? (In Ruby in particular)
I often need to do some operations in a loop and some other operations between the iterations. A simple example would be collecting words from an array into a string, spelled backwards and separated with commas. Is there an idiom or language support for this in any language? (For now i am mostly interested in Ruby.)
Are there languages that expand on the STL’s iterator types? [closed]
Closed 10 years ago.
Is it bad practice to make an iterator that is aware of its own end
For some background of why I am asking this question here is an example. In python the method chain
chains an arbitrary number of ranges together and makes them into one without making copies. Here is a link in case you don’t understand it. I decided I would implement chain in c++ using variadic templates. As far as I can tell the only way to make an iterator for chain that will successfully go to the next container is for each iterator to to know about the end of the container (I thought of a sort of hack in where when !=
is called against the end it will know to go to the next container, but the first way seemed easier and safer and more versatile).
Is it bad practice to make an iterator that is aware of its own end
For some background of why I am asking this question here is an example. In python the method chain
chains an arbitrary number of ranges together and makes them into one without making copies. Here is a link in case you don’t understand it. I decided I would implement chain in c++ using variadic templates. As far as I can tell the only way to make an iterator for chain that will successfully go to the next container is for each iterator to to know about the end of the container (I thought of a sort of hack in where when !=
is called against the end it will know to go to the next container, but the first way seemed easier and safer and more versatile).
Randomly and uniquely iterating over a range
Say you have a range of values (or anything else) and you want to iterate over the range and stop at some indeterminate point.
What are the advantages of next-iterator over this-iterator?
I don’t work too often with Java/C# iterators directly but when I do I always wonder what was the reason to design iterators in “next” fashion.
What are the advantages of next-iterator over this-iterator?
I don’t work too often with Java/C# iterators directly but when I do I always wonder what was the reason to design iterators in “next” fashion.
What are the advantages of next-iterator over this-iterator?
I don’t work too often with Java/C# iterators directly but when I do I always wonder what was the reason to design iterators in “next” fashion.
What are the advantages of next-iterator over this-iterator?
I don’t work too often with Java/C# iterators directly but when I do I always wonder what was the reason to design iterators in “next” fashion.