迭代的东西是如何被调用的?

发布于 2024-11-14 21:06:21 字数 574 浏览 3 评论 0原文

我想表达迭代器是 const (即你不能递增或递减它),但它产生的东西是非 const:

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

如果 iterator 是一个指针,我可以说:

指针 //迭代器

pointee //它产生的东西

但如果它不是一个指针,我'我不确定。我考虑过使用 container 来替代“pointee”,但迭代器根本不依赖于容器。例如,输入迭代器可以绑定到文件或 STDIN。以下内容有效并被其他人使用吗?

迭代器 //迭代器

iteratoo //它产生的东西

我很高兴得到任何指导!

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 is 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

桃扇骨 2024-11-21 21:06:21

“价值”是否太明显(或错误)?毕竟,您想要从迭代器中得到的是值。如果您指的是正在迭代的一组值,那么我认为“序列”不是一个坏选择。

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.

來不及說愛妳 2024-11-21 21:06:21

因为我们在聊天中讨论过这个问题,所以将其发布在这里。

使用胜利者/受害者设置。

迭代器 / Iteratim

或者你可以使用 Iteratee。

Posting this here since we discussed this in the chat.

Use the victor/victim setup.

Iterator / Iteratim

Or you could use Iteratee.

夜唯美灬不弃 2024-11-21 21:06:21

-and 后缀在英语中用于“要执行的事物”,例如 OED 给出的示例 multiplicand 表示“要相乘的事物”,以及 操作数表示“要操作的事物”。

那么 iterand 代表“要迭代的事物”呢?

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'?

怀里藏娇 2024-11-21 21:06:21

如果我说了很多次,我会说“引用对象”,或者如果我只说了一次,我会说“迭代器指向的东西”,并且担心有人可能会认为我在谈论 C++ 引用,从而造成任何混乱。

我还说指针的“被引用者”(而不是“被指向者”)。如果人们没有意识到指针和迭代器都是引用,尽管不是专门针对 C++ 的引用,那么他们总是可以接受教育的。

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.

烟火散人牵绊 2024-11-21 21:06:21

我不认为 iterator 有任何派生 - 无论是 iteratimitereeiterateeiterand 或任何其他合适的内容。为什么?因为迭代器不会对其指向的对象执行任何操作。其他答案建议的词语暗示正在迭代 iteratimiteratee 等。但事实并非如此。正在被指出。指针指向受指点。迭代器不会迭代被迭代者。

所以我认为最好是使用“pointee”这个词。

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.

记忆消瘦 2024-11-21 21:06:21

集合中的一个元素,无论是否迭代,都是一个项目。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文