|
|
|
|
|
by PaulDavisThe1st
17 days ago
|
|
But it's not a Python thing. Rust is noted below, and there's also C++. std::container<T> container;
for (std::container<T>::iterator i = container.begin(); i != container.end(); ++i) { ...}
auto iter = container.begin(); while (iter != container.end()) { ...; ++iter; }
for (auto const & t : container) { ... }
|
|
This is far more than most iterator designs allow, and as I said if you needed more this is very welcome, but if you didn't it's probably bad news.
C++ can sort iterators for example, so long as they're suitable for indexing back and forth as the sort progresses. Rust's sort functions are defined on its slice types, which makes sense in practical terms but if what you've got isn't quite a slice but could meet the requirements in C++ that's a problem for you.