Open aplavin opened 1 year ago
Maybe the semantics could be convert(Vector, dict)
? I've also come across situations where I have wanted this functionality (though in many way Dictionary
acts like a Vector
but with more general indexing so in general it seems like this could be avoided with generic programming).
convert
is a bag of worms - dictionaries assume the operation doesn’t affect the lookup of a key.
Hmm… what about hijacking vec
?
The most intuitive way to get the array of values from an
AbstractDictionary
iscollect(dict)
. However, it always allocates, even if values are readily available, as inDictionary.values
.I would like to propose creating a function that returns
dict.values
if it's present (egDictionary
), and doescollect(dict)
otherwise (egPairDictionary
). Not sure what it's name should be, though. It's likecollect
, but possibly without a copy.