It is recommended to use OrderedMap
this way:
import OrderedMap "mo:base/OrderedMap";
...
let natMap = Map.Make<Nat>(Nat.compare); // : Operations<Nat>
stable var keyStorage : Map.Map<Nat, Text> = natMap.empty<Text>();
But what if keyStorage
is a member of a structure?
{
...
keyStorage : Map.Map<Nat, Text>;
...
}
In this case, do you recommend natMap
be a global variable or a member of the same structure?
I think, better global, because it eliminates possible duplicates, but I am not 100% sure.