Andrei Alexandrescu: > That is debatable as it would make the same code do different things for > e.g. vectors and sparse vectors.
Iterating on the keys is more useful, in real-world programs. Regarding the names: - "keys", "values" return lazy iterators. "keys" returns a set-like object that supports an O(1) opIn_r (and eventually few other basic set operations). - "items" returns a lazy iterator of Tuple(key, value) (structs, then). This may also be named "pairs". - "allkeys", "allvalues", "allitems"/"allpairs" return arrays of items/vales/Tuple. If you want to keep the API small you can even omit "allkeys", "allvalues", "allitems" (so you need to do array(aa.keys) if you want them all. Bye, bearophile