About 7,450,000 results
Open links in new tab
  1. What are iterator, iterable, and iteration? - Stack Overflow

    Aug 24, 2023 · So an iterable is an object that you can get an iterator from. An iterator is an object with a next (Python 2) or __next__ (Python 3) method. Whenever you use a for loop, or map, …

  2. Difference between Python's Generators and Iterators

    Feb 5, 2015 · An iterator object is an object which implements the iterator protocol - a set of rules. In this case, it must have at least these two methods: __iter__ and __next__ . The __next__ …

  3. iterator - What does the "yield" keyword do in Python? - Stack …

    Oct 24, 2008 · See my references above, but in summary: an iterable has an __iter__ method returning an iterator. An iterator additionally provides a .__next__ method, which is implicitly …

  4. java - What is the difference between iterator and iterable and …

    Jul 28, 2011 · And Iterable, Collection and List just declare abstract method 'iterator()' and ArrayList alone implements it. I am going to show ArrayList source code with 'iterator()' method …

  5. Difference between Iterator and Spliterator in Java8

    Jul 21, 2018 · Spliterator == Splittable Iterator: it can split some source, and it can iterate it too. It roughly has the same functionality as an Iterator, but with the extra thing that it can potentially …

  6. Incrementing iterators: Is ++it more efficient than it++?

    Oct 26, 2018 · The reason is that if the iterator class itself is at all complex, then because it++ has to return the value before it is incremented, the implementation will generally make a copy. …

  7. loops - Ways to iterate over a list in Java - Stack Overflow

    The three forms of looping are nearly identical. The enhanced for loop:. for (E element : list) { . . . } is, according to the Java Language Specification, identical in effect to the explicit use of an …

  8. Newest 'Iterator' Questions - Stack Overflow

    The iterator has a large len so collecting the iterator and then writing the resulting vector isn't very ...

  9. Which is more efficient, a for-each loop, or an iterator?

    One reason to use the old C-style loop rather than the Iterator approach, regardless of whether it's the foreach or the desugar'd version, is garbage. Many data structures instantiate a new …

  10. How to iterate through a list of objects in C++?

    Mar 8, 2014 · First you need to read more about how to declare iterator variables. Hint: They are not templates. Secondly, while the iterator can in some ways be treated as a pointer, once you …