Enumerable Set Types, Ethereum, Solidity
Elaboration and optimization of the Solidity CRUD pattern at: https://github.com/rob-Hitchens/UnorderedKeySet
Four implementations:
- AddressSet
- Bytes32Set
- StringSet
- UintSet
import "./AddressSet.sol";
contract MyContract {
using AddressSet for AddressSet.Set;
AddressSet.Set myAddressSet;
...
myAddressSet.insert(newAddress);
myAddressSet.remove(oldAddress);
uint count = myAddressSet.count();
address key = myAddressSet.keyAtIndex(row);
struct User {
AddressSet.Set followerSet;
AddressSet.Set followingSet;
}
mapping(bytes32 => AddressSet.Set) productOwnerSets;
See SetTypeExamples.sol for example usage.