Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Iterator in Rust
Generator in Python
Iterator in Kotlin
Tips and Traps¶
- Notice that Iterable.map
returns a List instead of an iterator.
Since almost all collections in Kotlin eventually inherit from
Iterable
, themap
method of all collections (includingHashMap
) in Kotlin returns List.
Easy-Made Mistake with C++ Iterator
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
the wrong way
for(auto it=l.cbegin(); it!=l.cend(); ++it){
for(auto jt=++it; jt!=l.cend(); ++jt){
cout << *it << " <-> " << *jt << endl;
}
}
it is increased again in the inner …
Erase Elements of a Container Using Iterator in C++
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
@TODO: make a general discuss about removing elements form containers ...
vector -> best to remove backwards ...
You cannot erase elements from a container
using the function std::for_each
or the range-based for …