开发者

How's the thing iterated over called?

I wanted to express that an iterator is const (i.e you cannot increment or decrement it) but that the thing it yields is non-const:

iterator const it = foo.begin();
it++; // error
*it = ...; // not an error

If iterator i开发者_如何学Pythons a pointer, I can say:

pointer // the iterator

pointee // the thing it yields

But if it is not a pointer, I'm not sure. I thought about using container for the "pointee" substitute, but a iterator is not tied to a container at all. For example an input iterator can be tied to a file or to STDIN. Does the following work and is used by others?

iterator // the iterator

iteratoo // the thing it yields

I'm glad for any guidance!


Is "the value" too obvious (or wrong)? After all, what you want out of the iterator is the value. If you are referring to the set of values that you are iterating over then I think "sequence" is not a bad choice.


Posting this here since we discussed this in the chat.

Use the victor/victim setup.

Iterator / Iteratim

Or you could use Iteratee.


The -and suffix is used in English for 'thing to be acted on', for example the OED gives as examples multiplicand for 'thing to be multiplied', and operand for 'thing to be operated on'.

So what about iterand for 'thing to be iterated over'?


I would say "the referand" if I was saying it a lot, or "the thing the iterator points at" if I was just saying it once, and was worried about any confusion that someone might think I was talking about a C++ reference.

I also say "the referand" of a pointer (not the "pointee"). If people don't realise that pointers and iterators are both kinds of reference, despite not being specifically C++ references, they can always be educated.


I don't think any derivatives of iterator - be it iteratim, iteree, iteratee or iterand or whatever else are appropriate. Why? Because an iterator doesn't do anything to the thing it points to. The words suggested by other answers imply that an iteratim or iteratee etc. is being iterated. But it isn't. It is being pointed to. A pointer points to the pointee. An iterator doesn't iterate the iteratee.

So I think best is to use the word pointee.


An element of a collection, being iterated or not, is an item.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜