Iterators in C++ (stl) vs Java, is there a conceptual difference?

前端 未结 9 978
夕颜
夕颜 2020-12-13 09:30

I\'m returning to c++ after being away for a bit and trying to dust off the old melon.

In Java Iterator is an interface to a container having methods: hasNext

9条回答
  •  萌比男神i
    2020-12-13 09:52

    C++ iterators are a generalization of the pointer concept; they make it applicable to a wider range of situations. It means that they can be used to do such things as define arbitrary ranges.

    Java iterators are relatively dumb enumerators (though not so bad as C#'s; at least Java has ListIterator and can be used to mutate the collection).

提交回复
热议问题