Metadata-Version: 2.4
Name: segee
Version: 0.2.0
Summary: A high-performance, enterprise-grade Segment Tree implementation for Python
Project-URL: Homepage, https://github.com/nodashin6/segee
Project-URL: Documentation, https://github.com/nodashin6/segee/blob/main/docs/usage.md
Project-URL: Repository, https://github.com/nodashin6/segee.git
Project-URL: Issues, https://github.com/nodashin6/segee/issues
Author-email: nodashin <nodashin.jpn@gmail.com>
Maintainer-email: nodashin <nodashin.jpn@gmail.com>
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.
License-File: LICENSE
Keywords: algorithms,data-structures,range-query,segment-tree
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.12
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx-rtd-theme>=1.2.0; extra == 'docs'
Requires-Dist: sphinx>=5.0.0; extra == 'docs'
Provides-Extra: test
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
Requires-Dist: pytest>=7.0.0; extra == 'test'
Description-Content-Type: text/markdown

# 🌳 Segee

[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](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.
