* Implement AddressSet in terms of a generic Set * Add Uint256Set * Add EnumerableMap * Fix wording on EnumerableSet docs and tests * Refactor ERC721 using EnumerableSet and EnumerableMap * Fix tests * Fix linter error * Gas optimization for EnumerableMap * Gas optimization for EnumerableSet * Remove often not-taken if from Enumerable data structures * Fix failing test * Gas optimization for EnumerableMap * Fix linter errors * Add comment for clarification * Improve test naming * Rename EnumerableMap.add to set * Add overload for EnumerableMap.get with custom error message * Improve Enumerable docs * Rename Uint256Set to UintSet * Add changelog entry
34 lines
791 B
Solidity
34 lines
791 B
Solidity
pragma solidity ^0.6.0;
|
|
|
|
import "../utils/EnumerableSet.sol";
|
|
|
|
contract EnumerableSetMock {
|
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
|
|
event OperationResult(bool result);
|
|
|
|
EnumerableSet.AddressSet private _set;
|
|
|
|
function contains(address value) public view returns (bool) {
|
|
return _set.contains(value);
|
|
}
|
|
|
|
function add(address value) public {
|
|
bool result = _set.add(value);
|
|
emit OperationResult(result);
|
|
}
|
|
|
|
function remove(address value) public {
|
|
bool result = _set.remove(value);
|
|
emit OperationResult(result);
|
|
}
|
|
|
|
function length() public view returns (uint256) {
|
|
return _set.length();
|
|
}
|
|
|
|
function at(uint256 index) public view returns (address) {
|
|
return _set.at(index);
|
|
}
|
|
}
|