interval-search provides predicate-based binary and doubling search implementations
Project description
interval-search
interval-search provides predicate-based binary and doubling search implementations
Free software: MIT license
Documentation: https://interval-search.readthedocs.io.
import interval_search as inch
# inch.binary_search
list_ = [1, 10, 20, 500, 5000]
inch.binary_search(lambda x: list_[x] >= 20, 0, len(list_) - 1)
# -> 2
# inch.doubling_search
inch.doubling_search(lambda x: x >= 5) # -> 5
# with a lower bound to start searching at,
inch.doubling_search(lambda x: x >= 5, 10) # -> 10
# inch.interval_search
# uses binary search or doubling search
# depending on whether upper bound is specified
inch.interval_search(lambda x: list_[x] >= 20, 0, len(list_) - 1)
# -> 2
inch.interval_search(lambda x: x >= 5, 10) # -> 10
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.0.0 (2022-02-22)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
interval-search-0.5.1.tar.gz
(12.5 kB
view hashes)
Built Distribution
Close
Hashes for interval_search-0.5.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8166fd8d10c30fad5b7367078ed4a05da509bd45359410c7b1b88a58da3f127e |
|
MD5 | cac2f9c3d5d04377b3cb27ed00ed3c69 |
|
BLAKE2b-256 | fba3c4cf8e88ebbe5e7200fef3f7767428adaed408230a65b53767f84d815ed5 |