ArraysMock.sol 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.19;
  3. import {Arrays} from "../utils/Arrays.sol";
  4. contract Uint256ArraysMock {
  5. using Arrays for uint256[];
  6. uint256[] private _array;
  7. constructor(uint256[] memory array) {
  8. _array = array;
  9. }
  10. function findUpperBound(uint256 element) external view returns (uint256) {
  11. return _array.findUpperBound(element);
  12. }
  13. function unsafeAccess(uint256 pos) external view returns (uint256) {
  14. return _array.unsafeAccess(pos).value;
  15. }
  16. }
  17. contract AddressArraysMock {
  18. using Arrays for address[];
  19. address[] private _array;
  20. constructor(address[] memory array) {
  21. _array = array;
  22. }
  23. function unsafeAccess(uint256 pos) external view returns (address) {
  24. return _array.unsafeAccess(pos).value;
  25. }
  26. }
  27. contract Bytes32ArraysMock {
  28. using Arrays for bytes32[];
  29. bytes32[] private _array;
  30. constructor(bytes32[] memory array) {
  31. _array = array;
  32. }
  33. function unsafeAccess(uint256 pos) external view returns (bytes32) {
  34. return _array.unsafeAccess(pos).value;
  35. }
  36. }