All Questions
6
questions
1
vote
4
answers
1k
views
Should I always use iterators when working with strings?
Here is the known old way to iterate over the string:
for (int i = 0; i < str.length(); i++) {
char c = str[i];
}
However recently I have also seen in multiple places the usage of ...
1
vote
1
answer
220
views
How much an iterator should do
I am working on creating iterators, for strings, lists, trees, graphs, and potentially other things.
First a side note.
I have a string data type in my engine. The string is implemented as a bunch ...
3
votes
2
answers
125
views
Should I move tasks which is just for a specific element only out of for loop?
For example, I have a for loop, which element 0 has additional function to run compared with other elements, my question is, should the additional function be:
1.place inside for loop
for(int i=0;i&...
5
votes
3
answers
5k
views
Is implementing IEnumerable required to use foreach on collections?
I have the following class that doesn't implement IEnumerable but is working perfectly with foreach.
And also, arrays are working without implementing IEnumerable.
So why does it keep saying that ...
4
votes
1
answer
2k
views
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.
Because the stopping value could be anywhere in the range, iterating ...
4
votes
3
answers
334
views
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 ...