Skip to main content

Paginator

Overview​

License: MIT​

library Paginator

Library for pagination.

Supports the following data types uint256[], address[], bytes32[], UintSet, AddressSet, Bytes32Set, BytesSet, StringSet.

Functions info​

part​

function part(
uint256[] storage arr,
uint256 offset_,
uint256 limit_
) internal view returns (uint256[] memory list_)

Returns part of a uint256 array

Examples:

  • part([4, 5, 6, 7], 0, 4) will return [4, 5, 6, 7]
  • part([4, 5, 6, 7], 2, 4) will return [6, 7]
  • part([4, 5, 6, 7], 2, 1) will return [6]

Parameters:

NameTypeDescription
arruint256[]the storage array
offset_uint256the starting index in the array
limit_uint256the number of elements after the offset_

part​

function part(
address[] storage arr,
uint256 offset_,
uint256 limit_
) internal view returns (address[] memory list_)

Returns part of an address array

part​

function part(
bytes32[] storage arr,
uint256 offset_,
uint256 limit_
) internal view returns (bytes32[] memory list_)

Returns part of a bytes32 array

part​

function part(
EnumerableSet.UintSet storage set,
uint256 offset_,
uint256 limit_
) internal view returns (uint256[] memory list_)

Returns part of a uint256 set

Parameters:

NameTypeDescription
setstruct EnumerableSet.UintSetthe storage set
offset_uint256the starting index in the set
limit_uint256the number of elements after the offset

part​

function part(
EnumerableSet.AddressSet storage set,
uint256 offset_,
uint256 limit_
) internal view returns (address[] memory list_)

Returns part of an address set

part​

function part(
EnumerableSet.Bytes32Set storage set,
uint256 offset_,
uint256 limit_
) internal view returns (bytes32[] memory list_)

Returns part of a bytes32 set

part​

function part(
DynamicSet.BytesSet storage set,
uint256 offset_,
uint256 limit_
) internal view returns (bytes[] memory list_)

Returns part of a bytes set

part​

function part(
DynamicSet.StringSet storage set,
uint256 offset_,
uint256 limit_
) internal view returns (string[] memory list_)

Returns part of a string set

getTo​

function getTo(
uint256 length_,
uint256 offset_,
uint256 limit_
) internal pure returns (uint256 to_)

Returns the exclusive index of the element to iterate to

Parameters:

NameTypeDescription
length_uint256the length of the array
offset_uint256the starting index
limit_uint256the number of elements