Java和C ++中的迭代器 [英] Iterators in Java and C++

查看:152
本文介绍了Java和C ++中的迭代器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有点偏离主题,但我跳你会原谅我。


几天前有些人表达了意见(在一篇文章中我找不到,但

可能是在Razii的一个主题中)Java的迭代器比C ++迭代器更好,或者至少是Java迭代器概念

更好(或者那种效果)。我很想听听

为什么写这篇文章的人都有这种感觉。


-

Erik Wikstr ?? m

This is a little bit off topic but I hop you''ll forgive me.

A few days ago some expressed the opinion (in a post I can''t find, but
it was probably in one of Razii''s threads) that Java''s iterators were
better than C++ iterators, or at least that the Java iterator concept
was better (or something to that effect). I would be interested to hear
about why whoever wrote it feels that way.

--
Erik Wikstr??m

推荐答案

4月3日下午2:12 *,Erik Wikstr?m< Erik-wikst ... @ telia.comwrote:
On Apr 3, 2:12*pm, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

这是一个有点偏离主题但我跳你会原谅我。


几天前有些人表达了意见(在一篇我无法找到的帖子中,但是它可能是在Razii的一个帖子中),Java的迭代器比b / b
好​​。 C ++迭代器,
This is a little bit off topic but I hop you''ll forgive me.

A few days ago some expressed the opinion (in a post I can''t find, but
it was probably in one of Razii''s threads) that Java''s iterators were
better than C++ iterators,



你的意思是这个?

http://tinylink.com/?iaOmlBsgBy


在3 avr,21:12,Erik Wikstr?m< ; Erik-wikst ... @ telia.comwrote:
On 3 avr, 21:12, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

这有点偏离主题但我跳你会原谅我。
This is a little bit off topic but I hop you''ll forgive me.


前几天有人表达了意见(在帖子中我不能找到
,但它是可能在Razii的一个主题中)

Java的迭代器比C ++迭代器好,或者至少是
,Java迭代器概念更好(或者某事要

那种效果)。我很想知道为什么

写的人觉得这样。
A few days ago some expressed the opinion (in a post I can''t
find, but it was probably in one of Razii''s threads) that
Java''s iterators were better than C++ iterators, or at least
that the Java iterator concept was better (or something to
that effect). I would be interested to hear about why whoever
wrote it feels that way.



这就是我,原因很简单:你不需要两个

。例如,尝试链接使用迭代器的函数。

或编写过滤迭代器。


并非Java的迭代器也是完美的。合并访问

和递增 - 就像USL迭代器一样。当Java

正在开发时,我们已经确定这不是一个好主意,所以很难理解他们为什么这么做它。


-

James Kanze(GABI软件)电子邮件:ja ********* @ gmail.com

Conseils eninformatiqueorientéeobjet/

Beratung in objektorientierter Datenverarbeitung

9placeSémard,78210 St.-Cyr-l''coco,France,+ 33( 0)1 30 23 00 34

That was me, and the reason is simply: you don''t need two of
them. Try chaining functions which use iterators, for example.
Or writing a filtering iterator.

Not that Java''s iterators are perfect, either. The merge access
and incrementing---as did the USL iterators. By the time Java
was being developed, we''d already established that this wasn''t a
good idea, so it''s hard to understand why they did it.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l''école, France, +33 (0)1 30 23 00 34


2008-04-03 21:38, lb ******* @ yahoo.com 写道:
On 2008-04-03 21:38, lb*******@yahoo.com wrote:

4月3日下午2:12,Erik Wikstr? m< Erik-wikst ... @ telia.comwrote:
On Apr 3, 2:12 pm, Erik Wikstr??m <Erik-wikst...@telia.comwrote:

>这有点偏离主题但我跳你会原谅我。

前几天有些人表达了这个意见(在一篇我找不到的帖子中,但是可能是在Razii的一个帖子中)Java的迭代器w是否比C ++迭代器更好,
>This is a little bit off topic but I hop you''ll forgive me.

A few days ago some expressed the opinion (in a post I can''t find, but
it was probably in one of Razii''s threads) that Java''s iterators were
better than C++ iterators,



你的意思是这个?

http://tinylink.com/?iaOmlBsgBy



是的,谢谢。


詹姆斯,你能解释一下你所说的......对于大多数日常工作吗?这样的事实上,这是一个Java集合库(特别是

Java中迭代器的概念远远优于STL。?


虽然它是我上次使用Java之前的一段时间(仿制药之前)我'$

总是喜欢STL迭代器的方式,这是一个非常简单的概念但是

仍然非常强大。据我所知,使用Java的迭代器对容器子集执行

操作并不容易。


-

Erik Wikstr ?? m

Yes, thanks.

James, can you explain what you meant by "... for most everyday jobs
like this, in fact, the Java collections library (and especially the
concept of iterators in Java) is far superior to the STL."?

While it was some time ago since I last used Java (before generics) I''ve
always liked the way the STL iterators, it is a quite simple concept but
still very powerful. To my knowledge there is not easy way to perform
operations on a subset of a container using Java''s iterators.

--
Erik Wikstr??m


这篇关于Java和C ++中的迭代器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆