Are two list [“a”, “b”, “c”] and [1, 2, 3] always one-to-one corresponding relations (I know keys() order isn’t guaranteed)? e.g. keys() return [“b”, “a”, “c”], does values() return [2, 1, 3]?
As a sidenote, If you want to use an ordered map which has the same interface of Map module, check out OrderedMap which is implemented by Jonathan Storm.
Now you’ve got me trying to understand why keys and values are currently synced.
I found the definitions in erl_map.c but they seem to use a “yielding c fun” generated at compile-time which has defeated me. At least they both use the same erts_ycf_trap_driver function, which may result in the same enumeration order in both cases.
I haven’t looked at the source, but it’s probably different implementations based on map size. Try making a map with an arbitrarily large number of keys (>200) and I’m sure it’ll no longer be ordered