Re: [julia-users] Iterating over Dicts
(SortedDict is already in DataStructures.jl. To be added are SortedMultiDict and SortedSets.) Cheers! On Tue, Jul 21, 2015 at 4:43 PM, Yichao Yu yyc1...@gmail.com wrote: On Tue, Jul 21, 2015 at 7:37 PM, Benjamin Deonovic bdeono...@gmail.com wrote: A few clarifying questions. I believe that when you iterate over julia Dicts, the iteration is not necessarily in any particular order (i.e. if keys are alpha-numeric it is not necessarily in sorted order, or it is not necessarily in order the keys were inserted). Is that correct? Yes. If I set the seed though am I guaranteed the same order each time and between Julia sessions? Julia don't randomize it intentionally either and my guess is that the order would be repeatable if the hash function is (which might requires turning off address space randomization). Even then, this is not a defined behavior. If you want defined iteration order, see OrderedDict (and to be merged SortedDict) in DataStructures.jl Thanks Benjamin
[julia-users] Iterating over Dicts
A few clarifying questions. I believe that when you iterate over julia Dicts, the iteration is not necessarily in any particular order (i.e. if keys are alpha-numeric it is not necessarily in sorted order, or it is not necessarily in order the keys were inserted). Is that correct? If I set the seed though am I guaranteed the same order each time and between Julia sessions? Thanks Benjamin
Re: [julia-users] Iterating over Dicts
On Tue, Jul 21, 2015 at 7:37 PM, Benjamin Deonovic bdeono...@gmail.com wrote: A few clarifying questions. I believe that when you iterate over julia Dicts, the iteration is not necessarily in any particular order (i.e. if keys are alpha-numeric it is not necessarily in sorted order, or it is not necessarily in order the keys were inserted). Is that correct? Yes. If I set the seed though am I guaranteed the same order each time and between Julia sessions? Julia don't randomize it intentionally either and my guess is that the order would be repeatable if the hash function is (which might requires turning off address space randomization). Even then, this is not a defined behavior. If you want defined iteration order, see OrderedDict (and to be merged SortedDict) in DataStructures.jl Thanks Benjamin