ddlzz/bisect

A tiny library that implements the functionality of the Python bisect module

Maintainers

Details

github.com/ddlzz/bisect

Source

Issues

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

pkg:composer/ddlzz/bisect

1.0.1 2022-07-03 00:32 UTC

This package is auto-updated.

Last update: 2025-09-29 02:44:14 UTC


README

Code Coverage Scrutinizer Code Quality Packagist

A tiny library that implements the functionality of the Python bisect module in PHP language.

Quick start

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