* Add Arrays library with unit tests (#1209) * prepared due to snapshot token requirements * add library with method to find upper bound * add unit test for basic and edge cases * Imporove documentation for Arrays library Simplify Arrays.test.js to use short arrays as test date * Added comment for uint256 mid variable. * Explaned why uint256 mid variable calculated as Math.average is safe to use as index of array.
19 lines
332 B
Solidity
19 lines
332 B
Solidity
pragma solidity ^0.4.24;
|
|
|
|
import "../utils/Arrays.sol";
|
|
|
|
contract ArraysImpl {
|
|
|
|
using Arrays for uint256[];
|
|
|
|
uint256[] private array;
|
|
|
|
constructor(uint256[] _array) public {
|
|
array = _array;
|
|
}
|
|
|
|
function findUpperBound(uint256 _element) external view returns (uint256) {
|
|
return array.findUpperBound(_element);
|
|
}
|
|
}
|