I've recently come across Enumerable Maps and I'm a bit confused about when to use them.
According to the docs, maps have the following properties:
- Entries are added, removed, and checked for existence in constant time (O(1)).
- Entries are enumerated in O(n). No guarantees are made on the ordering.
Which I interpret as requiring one write operation and n read operations (n being the number of keys) to find if a value is in the map.
To me this sounds the same as an array. So my question is, when should I use an EnumerableMap vs when should I use an Array? I'm guessing EnumerableMap is used in those situations when a key/value pair is needed.
Bonus question. What are the differences in terms of gas cost for read and write operations?
Thank you very much.