码迷,mamicode.com
首页 > 移动开发 > 详细

[Contract] Solidity 遍历 mapping 的一种方式

时间:2020-02-25 23:15:28      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:The   points   rac   key   question   list   nts   length   ret   

 

思路:为需要遍历的 mapping 再准备一个 list,之后通过 for 循环遍历 list 取得 mapping 的 key。

 

mapping (address => uint) usersValue

mapping (uint => address) list

uint length = xx

for (uint i; i < length; i++) {

  usersValue[ list[i] ]

}

 

Ref:https://ethereum.stackexchange.com/questions/10915/could-mapping-data-structure-return-the-number-of-items-it-points

Link:https://www.cnblogs.com/farwish/p/12364291.html

[Contract] Solidity 遍历 mapping 的一种方式

标签:The   points   rac   key   question   list   nts   length   ret   

原文地址:https://www.cnblogs.com/farwish/p/12364291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!