PrioHeap
A priority queue from the textbooks. Python implementation is surprinsigly not modern.
Installation
pip3 install prioheap
Usage
The API is dead simple:
import prioheap
prio = prioheap.PrioHeap()
prio.add(0) # add element
prio.add(3)
prio.peak() # return highest element, e.g. 3
prio.add(1)
prio.pop() # remove and return highest element, 3.
len(prio), bool(prio) # those are supported
iter(prio), list(prio) # iterate elements in decreasing order
Test
To run the unit tests from the root of this repository:
python3 -m tests
License
License is Unlincense, so public domain.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
prioheap-0.0.2.tar.gz
(2.5 kB
view details)
File details
Details for the file prioheap-0.0.2.tar.gz.
File metadata
- Download URL: prioheap-0.0.2.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01a18fdc0e8c578d0e8fa2317ab20df080d9325822d9596a843eaca56295904c
|
|
| MD5 |
93f2345b911174ed465de5392f385aa4
|
|
| BLAKE2b-256 |
0e11914a350c8db6380c8d44073870f834a599df3742316c68ecc0964864a9bd
|