EnumerableSetMock.sol 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: MIT
  2. // This file was procedurally generated from scripts/generate/templates/EnumerableSetMock.js.
  3. pragma solidity ^0.8.0;
  4. import "../utils/structs/EnumerableSet.sol";
  5. // Bytes32Set
  6. contract EnumerableBytes32SetMock {
  7. using EnumerableSet for EnumerableSet.Bytes32Set;
  8. event OperationResult(bool result);
  9. EnumerableSet.Bytes32Set private _set;
  10. function contains(bytes32 value) public view returns (bool) {
  11. return _set.contains(value);
  12. }
  13. function add(bytes32 value) public {
  14. bool result = _set.add(value);
  15. emit OperationResult(result);
  16. }
  17. function remove(bytes32 value) public {
  18. bool result = _set.remove(value);
  19. emit OperationResult(result);
  20. }
  21. function length() public view returns (uint256) {
  22. return _set.length();
  23. }
  24. function at(uint256 index) public view returns (bytes32) {
  25. return _set.at(index);
  26. }
  27. function values() public view returns (bytes32[] memory) {
  28. return _set.values();
  29. }
  30. }
  31. // AddressSet
  32. contract EnumerableAddressSetMock {
  33. using EnumerableSet for EnumerableSet.AddressSet;
  34. event OperationResult(bool result);
  35. EnumerableSet.AddressSet private _set;
  36. function contains(address value) public view returns (bool) {
  37. return _set.contains(value);
  38. }
  39. function add(address value) public {
  40. bool result = _set.add(value);
  41. emit OperationResult(result);
  42. }
  43. function remove(address value) public {
  44. bool result = _set.remove(value);
  45. emit OperationResult(result);
  46. }
  47. function length() public view returns (uint256) {
  48. return _set.length();
  49. }
  50. function at(uint256 index) public view returns (address) {
  51. return _set.at(index);
  52. }
  53. function values() public view returns (address[] memory) {
  54. return _set.values();
  55. }
  56. }
  57. // UintSet
  58. contract EnumerableUintSetMock {
  59. using EnumerableSet for EnumerableSet.UintSet;
  60. event OperationResult(bool result);
  61. EnumerableSet.UintSet private _set;
  62. function contains(uint256 value) public view returns (bool) {
  63. return _set.contains(value);
  64. }
  65. function add(uint256 value) public {
  66. bool result = _set.add(value);
  67. emit OperationResult(result);
  68. }
  69. function remove(uint256 value) public {
  70. bool result = _set.remove(value);
  71. emit OperationResult(result);
  72. }
  73. function length() public view returns (uint256) {
  74. return _set.length();
  75. }
  76. function at(uint256 index) public view returns (uint256) {
  77. return _set.at(index);
  78. }
  79. function values() public view returns (uint256[] memory) {
  80. return _set.values();
  81. }
  82. }