I'm trying to to make a contract which lets the user choose any number he likes to populate an array of integers used in a mapping. Then he can choose any index of this array to increase its value by 1.
Below is the function that makes the increment:
pragma solidity ^0.4.19;
contract test {
//the array size is chosen by the user
mapping (bytes4 => int[]) internal map;
function _increase(bytes4 _id,uint _index) public {
map[_id][_index] = map[_id][_index] + 1;
}
}
The problem is, unless you give the array in the mapping a fixed number like:
mapping (bytes4 => int[1000]) internal map;
The function that increases its numbers throw an error (in remix):
Since giving this array any large random number to cover all the possibilities is a waste of unused space, can anyone think in a workarround?
Thanks a lot.