EnumerableMapHarness.sol 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {EnumerableMap} from "../patched/utils/structs/EnumerableMap.sol";
  4. contract EnumerableMapHarness {
  5. using EnumerableMap for EnumerableMap.Bytes32ToBytes32Map;
  6. EnumerableMap.Bytes32ToBytes32Map private _map;
  7. function set(bytes32 key, bytes32 value) public returns (bool) {
  8. return _map.set(key, value);
  9. }
  10. function remove(bytes32 key) public returns (bool) {
  11. return _map.remove(key);
  12. }
  13. function contains(bytes32 key) public view returns (bool) {
  14. return _map.contains(key);
  15. }
  16. function length() public view returns (uint256) {
  17. return _map.length();
  18. }
  19. function key_at(uint256 index) public view returns (bytes32) {
  20. (bytes32 key,) = _map.at(index);
  21. return key;
  22. }
  23. function value_at(uint256 index) public view returns (bytes32) {
  24. (,bytes32 value) = _map.at(index);
  25. return value;
  26. }
  27. function tryGet_contains(bytes32 key) public view returns (bool) {
  28. (bool contained,) = _map.tryGet(key);
  29. return contained;
  30. }
  31. function tryGet_value(bytes32 key) public view returns (bytes32) {
  32. (,bytes32 value) = _map.tryGet(key);
  33. return value;
  34. }
  35. function get(bytes32 key) public view returns (bytes32) {
  36. return _map.get(key);
  37. }
  38. function _positionOf(bytes32 key) public view returns (uint256) {
  39. return _map._keys._inner._positions[key];
  40. }
  41. }