https://github.com/pykit3/k3heap
k3heap is a binary min heap implemented with reference
https://github.com/pykit3/k3heap
heap python
Last synced: 4 months ago
JSON representation
k3heap is a binary min heap implemented with reference
- Host: GitHub
- URL: https://github.com/pykit3/k3heap
- Owner: pykit3
- License: mit
- Created: 2021-07-21T08:55:22.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-08-28T12:36:54.000Z (9 months ago)
- Last Synced: 2025-09-19T11:53:08.239Z (9 months ago)
- Topics: heap, python
- Language: Python
- Homepage: https://blog.openacid.com
- Size: 27.3 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# k3heap
[](https://github.com/pykit3/k3heap/actions/workflows/python-package.yml)
[](https://k3heap.readthedocs.io/en/stable/?badge=stable)
[](https://pypi.org/project/k3heap)
k3heap is a binary min heap implemented with reference
k3heap is a component of [pykit3] project: a python3 toolkit set.
In this module RefHeap is a binary min heap implemented with reference: a parent has two references to two children and a child has a parent reference to its parent.
RefHeap is not thread safe::
import k3heap
h = k3heap.RefHeap()
x = []
h.push(x)
h.push(x) # ValueError
h.push([]) # OK
# Install
```
pip install k3heap
```
# Synopsis
```python
import k3heap
h = k3heap.RefHeap([5, 1, 4, 2, 3])
while h.size > 0:
print(h.pop())
```
# Author
Zhang Yanpo (张炎泼)
# Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼)
[pykit3]: https://github.com/pykit3