Skip to main content

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

HeapDict-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

HeapDict-1.0.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

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

Hashes for HeapDict-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8495f57b3e03d8e46d5f1b2cc62ca881aca392fd5cc048dc0aa2e1a6d23ecdb6
MD5 095327c14b6104bd89c33c14b9ac0c39
BLAKE2b-256 5a9bd8963ae7e388270b695f3b556b6dc9adb70ae9618fba09aa1e7b1886652d

See more details on using hashes here.

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

Hashes for HeapDict-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6065f90933ab1bb7e50db403b90cab653c853690c5992e69294c2de2b253fc92
MD5 bc42a3c6dce9671e9818003cd2c71203
BLAKE2b-256 b69dcd4777dbcf3bef9d9627e0fe4bc43d2e294b1baeb01d0422399d5e9de319

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page