ArraysMock.sol 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  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 value) external view returns (uint256) {
  11. return _array.findUpperBound(value);
  12. }
  13. function lowerBound(uint256 value) external view returns (uint256) {
  14. return _array.lowerBound(value);
  15. }
  16. function upperBound(uint256 value) external view returns (uint256) {
  17. return _array.upperBound(value);
  18. }
  19. function lowerBoundMemory(uint256[] memory array, uint256 value) external pure returns (uint256) {
  20. return array.lowerBoundMemory(value);
  21. }
  22. function upperBoundMemory(uint256[] memory array, uint256 value) external pure returns (uint256) {
  23. return array.upperBoundMemory(value);
  24. }
  25. function unsafeAccess(uint256 pos) external view returns (uint256) {
  26. return _array.unsafeAccess(pos).value;
  27. }
  28. }
  29. contract AddressArraysMock {
  30. using Arrays for address[];
  31. address[] private _array;
  32. constructor(address[] memory array) {
  33. _array = array;
  34. }
  35. function unsafeAccess(uint256 pos) external view returns (address) {
  36. return _array.unsafeAccess(pos).value;
  37. }
  38. }
  39. contract Bytes32ArraysMock {
  40. using Arrays for bytes32[];
  41. bytes32[] private _array;
  42. constructor(bytes32[] memory array) {
  43. _array = array;
  44. }
  45. function unsafeAccess(uint256 pos) external view returns (bytes32) {
  46. return _array.unsafeAccess(pos).value;
  47. }
  48. }