ddlzz / bisect
一个实现Python bisect模块功能的微型库
1.0.1
2022-07-03 00:32 UTC
Requires
- php: ^7.1 | ^8
Requires (Dev)
- php: ^8.1
- friendsofphp/php-cs-fixer: ^3.8
- phpunit/phpunit: ^9.5
README
这是一个用PHP语言实现Python bisect模块功能的微型库。
快速开始
composer require ddlzz/bisect
<?php declare(strict_types=1); use Ddlzz\Bisect\Bisect; require_once 'vendor/autoload.php'; $sortedArray = [ // it works only with sorted arrays 23, 55, 127, 128, 200, 250, 300, 312, ]; $leftKey = Bisect::left($array, 100); // returns 2 $leftKey = Bisect::left($array, 55); // returns 1 $rightKey = Bisect::right($array, 55); // returns 2