https://github.com/pykit3/k3rangeset
segmented range which is represented in a list of sorted interleaving range.
https://github.com/pykit3/k3rangeset
python set
Last synced: 5 months ago
JSON representation
segmented range which is represented in a list of sorted interleaving range.
- Host: GitHub
- URL: https://github.com/pykit3/k3rangeset
- Owner: pykit3
- License: mit
- Created: 2021-07-29T07:55:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-08-28T12:38:08.000Z (10 months ago)
- Last Synced: 2025-09-19T11:53:08.325Z (9 months ago)
- Topics: python, set
- Language: Python
- Homepage: https://blog.openacid.com
- Size: 41 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# k3rangeset
[](https://github.com/pykit3/k3rangeset/actions/workflows/python-package.yml)
[](https://k3rangeset.readthedocs.io/en/stable/?badge=stable)
[](https://pypi.org/project/k3rangeset)
segmented range which is represented in a list of sorted interleaving range.
k3rangeset is a component of [pykit3] project: a python3 toolkit set.
Segmented range which is represented in a list of sorted interleaving range.
A range set can be thought as: `[[1, 2], [5, 7]]`.
# Install
```
pip install k3rangeset
```
# Synopsis
```python
import k3rangeset
a = k3rangeset.RangeSet([[1, 5], [10, 20]])
a.has(1) # True
a.has(8) # False
a.add([5, 7]) # [[1, 7], [10, 20]]
inp = [
[0, 1, [['a', 'b', 'ab'],
['b', 'd', 'bd'],
]],
[1, 2, [['a', 'c', 'ac'],
['c', 'd', 'cd'],
]],
]
r = k3rangeset.RangeDict(inp, dimension=2)
print(r.get(0.5, 'a')) # 'ab'
print(r.get(1.5, 'a')) # 'ac'
```
# Author
Zhang Yanpo (张炎泼)
# Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼)
[pykit3]: https://github.com/pykit3