0

Given I want to return a mapping from a function, which is impossible, therefore I return each of the mapping's item in a function by a corresponding ID, like this answer suggests : How to return a mapping type?

Given I want to iterate over all existing IDs in a mapping in order to retrieve all user assets, how long does it take to call a single iteration ?

Random
  • 203
  • 1
  • 2
  • 6
  • You cannot iterate over a mapping in solidity, unless you hold the key types in a collection such as an array and access their corresponding value in the mapping one-by-one. – Harry Wright Jan 12 '18 at 11:51
  • @HarryWright This is exactly what I asked, one-by-one, I know my IDs will be, say, 1-10, because say I want to delete from my mapping, I need to delete from the array, and that is inefficient. – Random Jan 12 '18 at 11:52
  • As a followup of my previous question https://ethereum.stackexchange.com/questions/35790/efficient-approach-to-delete-element-from-array-in-solidity – Random Jan 12 '18 at 11:58

0 Answers0