The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
3answers
139 views

Alternatives to foreach iterators involving ref and out

I am trying to make a flexible particle system for my XNA game, and I've got these interfaces: public interface IParticle : IUpdateable { bool Alive { get; } float Percent { get; } } public ...
1
vote
3answers
104 views

Best way to find whether a collection does or does not contain an element with a specific desired quality

It seems to be a very common thing to have to tell whether some list or set contains at least one object matching a given condition, yet my prior searching and reading have never found a satisfactory ...
1
vote
2answers
190 views

Python sorted iterable set, modifiable during iteration

I am looking for a datastructure to handle cycling through a large number of ordered subroutines, some of which are active, most of which are not. I am thinking I need an implementation of a python ...
5
votes
2answers
188 views

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. In order to start you have to move iterator, in order ...
1
vote
1answer
123 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
3answers
1k views

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 ...
6
votes
3answers
159 views

Are there languages that expand on the STL's iterator types?

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 ...
4
votes
3answers
250 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 ...
1
vote
2answers
562 views

Nice iterator naming [closed]

How do you name your iterators when you return a begin and an end iterator from a class? Without it sounding clunky, that is. Example: typedef std::vector<Idea> Ideas_Type; ...
0
votes
1answer
554 views

PHP, when to use iterators, how to buffer results?

When is it best to use Iterators in PHP, and how can they be implemented to best avoid loading all objects into memory simultaneously? Do any constructs exist in PHP so that we can queue up results ...
8
votes
1answer
1k views

Why do Java's Iterator and ListIterator point between elements?

The Javadoc for ListIterator says: A ListIterator has no current element; its cursor position always lies between the element that would be returned by a call to previous() and the element ...
9
votes
4answers
346 views

Does an iterator have a non-destructive implied contract?

Let's say I'm designing a custom data structure like a stack or a queue (for example - could be some other arbitrary ordered collection that has the logical equivalent of push and pop methods - ie ...
21
votes
4answers
6k views

Why do iterators in Python raise an exception?

Here's the syntax for iterators in Java (somewhat similar syntax in C#): Iterator it = sequence.iterator(); while (it.hasNext()) { System.out.println(it.next()); } Which makes sense. Here's ...
5
votes
3answers
365 views

Is “3 or more use a for” a good rule of thumb?

When do repetitive operations become a code smell? I read this article by Charles Petzold where he suggested this and was wondering what people thought.
0
votes
2answers
805 views

Question regarding LinkedList in Java

When I was reading a book for SCJP, I came across the following paragraph. A LinkedList is ordered by index position, like ArrayList, except that the elements are doubly-linked to one another. ...
0
votes
2answers
543 views

Enumerators vs. returning

I've been reading over the Enumerable module in Ruby, and it contains a few methods that follow the pattern of enum.foo(n) {|obj| block } → nil enum.foo(n) → an_enumerator Which is to say, they ...
1
vote
2answers
182 views

Does anyone else feel that iterator syntax sugar is a must have in a modern language?

I work with C# professionally and I write code like this all the time. private IEnumerable<Something> GetAlotOfSomething() { if (somethingA.IsReady) yield return somethingA; if ...