Top "Iterator" questions

An iterator is an object-oriented programming pattern that allows traversal through a collection, agnostic of the actual implementation or object addresses in physical memory.

Scala downwards or decreasing for loop?

In Scala, you often use an iterator to do a for loop in an increasing order like: for(i <…

scala iterator loops for-loop
Why is Java's Iterator not an Iterable?

Why does the Iterator interface not extend Iterable? The iterator() method could simply return this. Is it on purpose or …

java iterator iterable
Efficient looping through AS3 dictionary

for (var k in dictionary) { var key:KeyType = KeyType(k); var value:ValType = ValType(dictionary[k]); // <-- lookup // do …

actionscript-3 iterator iteration
One-liner to check whether an iterator yields at least one element?

Currently I'm doing this: try: something = iterator.next() # ... except StopIteration: # ... But I would like an expression that I can place …

python iterator
Iterate over vector of pair

I have written following code snippet but it does not seem to be working. int main(){ int VCount, v1, v2; …

c++ vector stl iterator const-iterator
Need iterator when using ranged-based for loops

Currently, I can only do ranged based loops with this: for (auto& value : values) But sometimes I need an …

c++ c++11 for-loop iterator
Is there a C++ iterator that can iterate over a file line by line?

I would like to get an istream_iterator-style iterator that returns each line of the file as a string rather …

c++ file iterator newline line
Find position of element in C++11 range-based for loop?

Assume I have the following code: vector<int> list; for(auto& elem:list) { int i = elem; } Can …

c++ iterator c++11
Using map() on an iterator

Say we have a Map: let m = new Map();, using m.values() returns a map iterator. But I can't use …

javascript dictionary syntax ecmascript-6 iterator
JavaScript - Nuances of myArray.forEach vs for loop

I've seen plenty of questions that suggest using: for (var i = 0; i < myArray.length; i++){ /* ... */ } instead of: for (var …

javascript arrays for-loop internet-explorer-8 iterator