Name | segee JSON |
Version |
0.2.0
JSON |
| download |
home_page | None |
Summary | A high-performance, enterprise-grade Segment Tree implementation for Python |
upload_time | 2025-08-27 22:12:52 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | MIT License
Copyright (c) 2025 nodashin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
algorithms
data-structures
range-query
segment-tree
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 🌳 Segee
[](https://www.python.org/downloads/)
[](LICENSE)
Python data structures library for efficient range queries and updates.
## ✨ Features
- **Segment Trees**: Range queries with any associative operation (sum, min, max, GCD, etc.)
- **Binary Indexed Trees**: Efficient sum queries and updates for additive operations
- **Type Safety**: Generic type hints with protocol-based constraints
- **Pure Python**: Zero dependencies, works with Python 3.12+
- **Comprehensive Testing**: 232 tests including real-world problem validation
- **Pythonic API**: Full sequence protocol support (`tree[i]`, `len(tree)`, etc.)
## 🚀 Quick Start
```python
from segee import SumSegmentTree, MinSegmentTree, BinaryIndexedTree
# Segment Trees - for any associative operation
sum_tree = SumSegmentTree(5)
sum_tree[0:5] = [1, 2, 3, 4, 5]
print(sum_tree.sum(1, 4)) # 9 (sum of indices 1-3)
min_tree = MinSegmentTree(5)
min_tree[0:5] = [10, 5, 20, 15, 8]
print(min_tree.minimum(1, 4)) # 5 (min of indices 1-3)
# Binary Indexed Trees - optimized for additive operations
bit = BinaryIndexedTree([1, 2, 3, 4, 5])
bit.add(2, 10) # Add 10 to index 2
print(bit.sum(0, 5)) # 25 (sum of all elements)
# Custom operations with generic segment tree
import math
from segee import GenericSegmentTree
gcd_tree = GenericSegmentTree(5, 0, math.gcd)
```
## 📦 Installation
```bash
pip install segee
```
## 🏗️ Available Data Structures
### Segment Trees
- `GenericSegmentTree[T]` - Generic implementation for any associative operation
- `SumSegmentTree` - Optimized for sum operations
- `MinSegmentTree` - Optimized for minimum operations
- `MaxSegmentTree` - Optimized for maximum operations
### Binary Indexed Trees
- `GenericBinaryIndexedTree[T]` - Generic implementation for additive operations
- `BinaryIndexedTree` - Optimized for int/float types
- `RangeAddBinaryIndexedTree` - Supports efficient range updates
### 🎯 Interactive CLI
```bash
# Launch interactive segment tree CLI
segee
```
## 🏛️ Architecture
```
segee/
├── segment_tree/ # Segment tree module
│ ├── backbone/ # Generic implementations
│ └── specialized/ # Sum/Min/Max classes
├── binary_indexed_tree/ # Binary indexed tree module
│ ├── backbone/ # Generic implementations
│ └── specialized/ # Optimized classes
├── shared/ # Shared protocols and mixins
└── segee_cli/ # Interactive CLI application
```
## 📚 Documentation
- [Usage Guide](docs/usage.md) - Examples and usage patterns
- [API Reference](docs/api.md) - Complete method documentation
- [Performance Guide](docs/performance.md) - Complexity analysis and benchmarks
- [Contributing](docs/contributing.md) - Development guidelines
## 🤔 When to Use
- **Segment Trees**: When you need range queries with custom operations (min, max, GCD, XOR, etc.)
- **Binary Indexed Trees**: When you need fast sum queries and updates, or range sum with range updates
## 📄 License
MIT License - see [LICENSE](LICENSE) for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "segee",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "nodashin <nodashin.jpn@gmail.com>",
"keywords": "algorithms, data-structures, range-query, segment-tree",
"author": null,
"author_email": "nodashin <nodashin.jpn@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/88/3a/0a00b44439d80df52249186b2c8bb5410a7492bc8ff078e56506e64ab188/segee-0.2.0.tar.gz",
"platform": null,
"description": "# \ud83c\udf33 Segee\n\n[](https://www.python.org/downloads/)\n[](LICENSE)\n\nPython data structures library for efficient range queries and updates.\n\n\n## \u2728 Features\n\n- **Segment Trees**: Range queries with any associative operation (sum, min, max, GCD, etc.)\n- **Binary Indexed Trees**: Efficient sum queries and updates for additive operations\n- **Type Safety**: Generic type hints with protocol-based constraints\n- **Pure Python**: Zero dependencies, works with Python 3.12+\n- **Comprehensive Testing**: 232 tests including real-world problem validation\n- **Pythonic API**: Full sequence protocol support (`tree[i]`, `len(tree)`, etc.)\n\n## \ud83d\ude80 Quick Start\n\n```python\nfrom segee import SumSegmentTree, MinSegmentTree, BinaryIndexedTree\n\n# Segment Trees - for any associative operation\nsum_tree = SumSegmentTree(5)\nsum_tree[0:5] = [1, 2, 3, 4, 5]\nprint(sum_tree.sum(1, 4)) # 9 (sum of indices 1-3)\n\nmin_tree = MinSegmentTree(5)\nmin_tree[0:5] = [10, 5, 20, 15, 8]\nprint(min_tree.minimum(1, 4)) # 5 (min of indices 1-3)\n\n# Binary Indexed Trees - optimized for additive operations\nbit = BinaryIndexedTree([1, 2, 3, 4, 5])\nbit.add(2, 10) # Add 10 to index 2\nprint(bit.sum(0, 5)) # 25 (sum of all elements)\n\n# Custom operations with generic segment tree\nimport math\nfrom segee import GenericSegmentTree\ngcd_tree = GenericSegmentTree(5, 0, math.gcd)\n```\n\n## \ud83d\udce6 Installation\n\n```bash\npip install segee\n```\n\n## \ud83c\udfd7\ufe0f Available Data Structures\n\n### Segment Trees\n- `GenericSegmentTree[T]` - Generic implementation for any associative operation\n- `SumSegmentTree` - Optimized for sum operations\n- `MinSegmentTree` - Optimized for minimum operations\n- `MaxSegmentTree` - Optimized for maximum operations\n\n### Binary Indexed Trees\n- `GenericBinaryIndexedTree[T]` - Generic implementation for additive operations\n- `BinaryIndexedTree` - Optimized for int/float types\n- `RangeAddBinaryIndexedTree` - Supports efficient range updates\n\n### \ud83c\udfaf Interactive CLI\n```bash\n# Launch interactive segment tree CLI\nsegee\n```\n\n## \ud83c\udfdb\ufe0f Architecture\n\n```\nsegee/\n\u251c\u2500\u2500 segment_tree/ # Segment tree module\n\u2502 \u251c\u2500\u2500 backbone/ # Generic implementations\n\u2502 \u2514\u2500\u2500 specialized/ # Sum/Min/Max classes\n\u251c\u2500\u2500 binary_indexed_tree/ # Binary indexed tree module\n\u2502 \u251c\u2500\u2500 backbone/ # Generic implementations\n\u2502 \u2514\u2500\u2500 specialized/ # Optimized classes\n\u251c\u2500\u2500 shared/ # Shared protocols and mixins\n\u2514\u2500\u2500 segee_cli/ # Interactive CLI application\n```\n\n\n## \ud83d\udcda Documentation\n\n- [Usage Guide](docs/usage.md) - Examples and usage patterns\n- [API Reference](docs/api.md) - Complete method documentation\n- [Performance Guide](docs/performance.md) - Complexity analysis and benchmarks\n- [Contributing](docs/contributing.md) - Development guidelines\n\n\n## \ud83e\udd14 When to Use\n\n- **Segment Trees**: When you need range queries with custom operations (min, max, GCD, XOR, etc.)\n- **Binary Indexed Trees**: When you need fast sum queries and updates, or range sum with range updates\n\n## \ud83d\udcc4 License\n\nMIT License - see [LICENSE](LICENSE) for details.\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 nodashin\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "A high-performance, enterprise-grade Segment Tree implementation for Python",
"version": "0.2.0",
"project_urls": {
"Documentation": "https://github.com/nodashin6/segee/blob/main/docs/usage.md",
"Homepage": "https://github.com/nodashin6/segee",
"Issues": "https://github.com/nodashin6/segee/issues",
"Repository": "https://github.com/nodashin6/segee.git"
},
"split_keywords": [
"algorithms",
" data-structures",
" range-query",
" segment-tree"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a2a4add8fd36a51526f6a01e0f65dfea5d21f4feb26c49b7911dca5f8b1fbf7a",
"md5": "66fa089e4741f7c96ca27dbb5ec812af",
"sha256": "12d67eb393707ed89e1dc28c30e83af4b6cead84f19eeb501d9cdc1777319de1"
},
"downloads": -1,
"filename": "segee-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "66fa089e4741f7c96ca27dbb5ec812af",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 35336,
"upload_time": "2025-08-27T22:12:51",
"upload_time_iso_8601": "2025-08-27T22:12:51.376754Z",
"url": "https://files.pythonhosted.org/packages/a2/a4/add8fd36a51526f6a01e0f65dfea5d21f4feb26c49b7911dca5f8b1fbf7a/segee-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "883a0a00b44439d80df52249186b2c8bb5410a7492bc8ff078e56506e64ab188",
"md5": "3b6cef02dc2c6d1e69fb67ea3e997be6",
"sha256": "b0d87952276ab9beb7984f254ab811580415fdeaae114f45f31acc36ebd7618b"
},
"downloads": -1,
"filename": "segee-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "3b6cef02dc2c6d1e69fb67ea3e997be6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 34755,
"upload_time": "2025-08-27T22:12:52",
"upload_time_iso_8601": "2025-08-27T22:12:52.518231Z",
"url": "https://files.pythonhosted.org/packages/88/3a/0a00b44439d80df52249186b2c8bb5410a7492bc8ff078e56506e64ab188/segee-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-27 22:12:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nodashin6",
"github_project": "segee",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "segee"
}