Associative
Arcology Hash Maps
In Arcology, the map functions as a data structure that combines the features of an ordered map and an array.
Issues with Mapping in Solidity
Solidity's mapping is similar to hash maps in other languages, but it has some major differences comparing to them:
Direct Iteration: Mappings do not support direct iteration. To iterate over keys or values, you need to maintain an auxiliary data structure, like an array, to store the keys separately.
Existence Check: There's no direct method to check if a key exists. You have to infer the existence based on the default value for the value type or maintain a separate boolean mapping.
Deletion of Keys: You can delete a key in a mapping using the
delete
keyword, but it only resets the value to its default state.Storage-Based: Solidity mappings are primarily used for storing data on the blockchain. Each key-value pair is stored in the contract's storage, which is persistent and incurs storage costs.
Concurrent Maps
In Arcology, the map permits access to elements via keys and supports iteration in the order of insertion. Additionally, the maps offer enhanced functionalities such as key retrieval by index and explicit verification of key presence. Arcology's Hash Maps can be configured as in-memory or in-storage, offering greater flexibility in data management.
Supported Data Types
Currently, the following data types are supported by the container:
Address / Boolean
Address / U256
String / U256
U256 / U256
Custom Types: You can always derive maps of custom types from the Base contract
. Developers can build their own HashMap of custom types using the base container provided by Arcology.
Last updated