a heap with decrease-key and increase-key operations
Project description
heapdict implements the MutableMapping ABC, meaning it works pretty much like a regular Python dict. It’s designed to be used as a priority queue, where items are added and consumed as follows:
hd = heapdict() hd[obj1] = priority1 hd[obj2] = priority2 # ... (obj, priority) = hd.popitem()
Compared to an ordinary dict, a heapdict has the following differences:
- popitem():
Remove and return the (key, priority) pair with the lowest priority, instead of a random object.
- peekitem():
Return the (key, priority) pair with the lowest priority, without removing it.
Unlike the Python standard library’s heapq module, the heapdict supports efficiently changing the priority of an existing object (often called “decrease-key” in textbooks). Altering the priority is important for many algorithms such as Dijkstra’s Algorithm and A*.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file HeapDict-1.0.1.tar.gz.
File metadata
- Download URL: HeapDict-1.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8495f57b3e03d8e46d5f1b2cc62ca881aca392fd5cc048dc0aa2e1a6d23ecdb6
|
|
| MD5 |
095327c14b6104bd89c33c14b9ac0c39
|
|
| BLAKE2b-256 |
5a9bd8963ae7e388270b695f3b556b6dc9adb70ae9618fba09aa1e7b1886652d
|
File details
Details for the file HeapDict-1.0.1-py3-none-any.whl.
File metadata
- Download URL: HeapDict-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6065f90933ab1bb7e50db403b90cab653c853690c5992e69294c2de2b253fc92
|
|
| MD5 |
bc42a3c6dce9671e9818003cd2c71203
|
|
| BLAKE2b-256 |
b69dcd4777dbcf3bef9d9627e0fe4bc43d2e294b1baeb01d0422399d5e9de319
|