-
Discord user ID0xhepha Describe your question in detail.I learned long ago that it all depends on the implementation when working with arrays,list,maps,tables,etc The question that started to round my head when choosing "vector vs table" to manage a whitelist of structs is... how does a table work? An array management is almost the same no matter where you go, but tables, sometimes are coded just for usability, to have a clearer code, while simulating an indexed map, they actually use normal array iteration instead of some sorts of indexing. Lets use cointains() function as an example, does it use some kind of indexing, or is just pure check every element of the list kind of implementation and does an O(n) timing? Is this true when speaking about table functions?
What error, if any, are you getting?No response What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?Windows Which SDK or tool are you using? (if any)TypeScript SDK Describe your environment or tooling in detailNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you don't care about order, you can use Table or SmartTable. This should work similar as hash map so roughly O(1). If you want indexed map which is O(logN), there's an open PR to add IndexedMap to the aptos framework, aptos-labs/aptos-core#14872 If you use vector or SimpleMap, it's O(N) |
Beta Was this translation helpful? Give feedback.
If you don't care about order, you can use Table or SmartTable. This should work similar as hash map so roughly O(1).
If you want indexed map which is O(logN), there's an open PR to add IndexedMap to the aptos framework, aptos-labs/aptos-core#14872
If you use vector or SimpleMap, it's O(N)