Honestly i never really thought about size_hint; changing it to len_hint makes sense to me.
front/back vs first/last is trickier.
front/back is industry standard terminology for deques. push_first/push_last looks pretty weird to me. Not insane, just weird. However the front/back metaphor was considered a bit more tenuous in other cases like arrays and stacks, which have more of a numbered or top/bottom metaphor. We do model double-ended-iterators as deques (next_back), but it’s asymmetric with normal iterators (next) because almost no one actually uses next_back – it’s largely just for rev. So talking about the front or back of an iterator can be a bit weird (just like talking about the front or back of an array).
We used to have some more exotic terminology-unification around collections (you pushed and poped a Map), but that was dropped.
Somewhat unrelated, std::iter::IteratorExt trait also has a method named last
but it has O(n) complexity. I think that’s pretty dangerous for
performance, because the common assumption is that methods named like last or back are O(1).
Disagree. Anyone coming from a functional language knows all-too-well that getting the last element of a sequence can be very expensive. Anyone otherwise familiar with singly linked lists should as well. first and last also strike me as quite niche pieces of iterator functionality, and therefore lower priority.
Regardless with specialization (eventually) we can make these operations legit O(1) for almost all the iterators you’ll work with in practice.
Oof, hour long video for motivation. I haven’t watched this particular Scott Meyers video, but from what I’ve seen from him before he’s more concerned with serious pitfalls and a swamp of special cases. I’m not sure different naming conventions for different APIs is necessarily the kind of thing he’s all that concerned about.