Metadata-Version: 2.4
Name: hashdeque
Version: 0.0.2
Summary: A string/bytes deque with an O(1) rolling hash and O(1) equality between instances.
Project-URL: Homepage, https://github.com/dheeraj-6904/RollingHashDeque
Project-URL: Repository, https://github.com/dheeraj-6904/RollingHashDeque
Project-URL: Issues, https://github.com/dheeraj-6904/RollingHashDeque/issues
Author-email: dheeraj-6904 <dheerajmandoliya@gmail.com>
License: MIT License
        
        Copyright (c) 2026 dheeraj-6904
        
        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: deque,hashdeque,hashing,rabin-karp,rolling-hash,sliding-window
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: repo-structure; extra == 'dev'
Description-Content-Type: text/markdown

# hashdeque

A **deque of characters** (any Unicode symbol) that maintains a **rolling hash**
of its contents. Powers of the base are precomputed, so the hash of the current
sequence is available in **O(1)** after each push/pop instead of rehashing
everything.

- `push_front` / `push_back` — **O(1)**
- `pop_front` / `pop_back` — **O(1)**
- `hash()` of the current contents — **O(1)**
- equality between two `HashDeque` instances — **O(1)** (compares rolling hashes)

Useful for substring/window matching (Rabin–Karp style), deduplication over a
sliding window, and content-defined chunking.

## Install

```bash
pip install hashdeque
```

Development setup:

```bash
uv venv
uv pip install -e ".[dev]"
```

## Usage

```python
from hashdeque import HashDeque

d = HashDeque()
for ch in "hello":
    d.push_back(ch)
print(d.hash())     # rolling-hash fingerprint of "hello"
d.pop_front()       # drop 'h'
print(d.hash())     # fingerprint of "ello", computed in O(1)

other = HashDeque("ello")
print(d == other)   # True, O(1) comparison

d.verify = True     # opt in to exact verification on a hash match
```

## Test

```bash
pytest
```

## Layout

```
hashdeque/
├── pyproject.toml
├── repo_structure.yaml         # enforced by the repo-structure pre-commit hook
├── .pre-commit-config.yaml
├── .github/workflows/publish.yml
├── src/hashdeque/
│   ├── __init__.py             # public API
│   ├── base.py                 # BaseHashDeque (ABC) — the contract
│   ├── params.py               # HashParams — bases/moduli/inverses
│   ├── deque.py                # HashDeque — polynomial double-hash implementation
│   └── py.typed
└── tests/
    ├── test_base.py
    ├── test_params.py
    └── test_hashdeque.py
```
