{
    "Function": "findUpperBound",
    "File": "contracts/lib/openzeppelin-contracts/contracts/utils/Arrays.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "Math"
    ],
    "Internal Calls": [],
    "Library Calls": [
        "average"
    ],
    "Low-Level Calls": [],
    "Code": "function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n        if (array.length == 0) {\n            return 0;\n        }\n\n        uint256 low = 0;\n        uint256 high = array.length;\n\n        while (low < high) {\n            uint256 mid = Math.average(low, high);\n\n            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n            // because Math.average rounds down (it does integer division with truncation).\n            if (array[mid] > element) {\n                high = mid;\n            } else {\n                low = mid + 1;\n            }\n        }\n\n        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.\n        if (low > 0 && array[low - 1] == element) {\n            return low - 1;\n        } else {\n            return low;\n        }\n    }"
}