interval-search¶

https://img.shields.io/pypi/v/interval-search.svg https://img.shields.io/travis/mmore500/interval-search.svg Documentation Status

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.

interval-search

Navigation

Contents:

  • interval-search
    • Credits
  • Installation
  • Usage
  • Contributing
  • Credits
  • History

Related Topics

  • Documentation overview
    • Previous: Welcome to interval-search’s documentation!
    • Next: Installation

Quick search

©2022, Matthew Andres Moreno. | Powered by Sphinx 5.3.0 & Alabaster 0.7.13 | Page source