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

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

思路:为需要遍历的 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] ]

}

 

其它:基础矿池

Refer:Solidity的遍历方式

Refer: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

posted on 2020-02-25 22:26  ercom  阅读(4292)  评论(0编辑  收藏  举报