Interval Tree for Python
This is a Cython-wrapped red-black interval tree from IvanPinezhaninov/IntervalTree/.
To install:
pip install rbi-tree
Example usage:
>>> from rbi_tree.tree import ITree
>>> t = ITree()
>>> t.insert(60, 80, value={'a':'b'}) # start stop are integers
>>> t.insert(20, 40)
>>> t.find(10, 30)
[(20, 40, None)]
>>> t.find(40, 60) # half open so it gives nothing
[]
>>> t.find(40, 61)
[(60, 80, {'a': 'b'})]
Class rbi_tree.tree.ITreed supports interval deletion. This is done via
values assigned automatically and serving as IDs for intervals.
>>> from rbi_tree.tree import ITreed
>>> t = ITreed()
>>> id1 = t.insert(60, 80) # start stop are integers
>>> id1
0
>>> id2 = t.insert(20, 40)
>>> id2
1
Ids are incrementing integers starting from zero reflecting number of insertion events.
>>> t.find(10, 30)
[(20, 40, 0)]
Ids of intervals can be used to remove them:
>>> t.remove(1)
>>> t.find(10, 30) # now it finds nothing
[]
>>> t.find_at(70) # search at point
[(60, 80, 0)]
>>> list(t.iter_ivl())
[(60, 80, 0)]
Metadata
Release files for rbi-tree 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rbi_tree-0.2.tar.gz | 89.9 kB | Without provenance | Details for rbi_tree-0.2.tar.gz |
Release files / rbi_tree-0.2.tar.gz
| Download URL | rbi_tree-0.2.tar.gz |
|---|---|
| Size | 89.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
322f73424a95b416749592902d797c9f62666c0d69d8c2eab969816635028fa1
|
|
BLAKE2b-256 checksum How to use checksums |
9463b8c486b962c698696c565fef10bccb755179effa9a32654fd9c26e0b3817
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for rbi-tree 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.