Skip to main content

heap-mapping

This is a library containing an implementation of the min-max heap data structure, which allows for $O(1)$ retrieval and $O(log(n))$ removal of both the minimum and maximum elements of the heap, as well as $O(log(n))$ insertion of keys and changes to their priorities. Heap creation can be additionally performed in $O(n)$ time.

The data structure can be accessed as MutableMapping; keys are the "values" stored in the data structure, and values are their priorities.

Getting started

You can construct a MinMaxHeap from a list of values.

from heap_mapping import MinMaxHeap

heap = MinMaxHeap([5, 0, 4, 1, 2, 9, 8])
print(heap.min_value) # 0
print(heap.max_value) # 9

By default, priorities are the same as the values.

print(heap[5]) # 5

You can specify a key function in the constructor to get a priority from each element.

heap2 = MinMaxHeap([5, 0, 4, 1, 2, 9, 8], key=lambda x: -x)
print(heap2.min_value) # 9
print(heap2.max_value) # 0
print(heap2[5]) # -5

You can add elements with the add method. By default, the key function specified in the constructor is used to get the priority.

heap2.add(7)
print(heap2[7]) # -7

Alternatively, you can manually specify a key.

heap2.add(6, -3)
print(heap2[6]) # -3

You can change the priorities after they've been inserted.

heap2[7] = 1
print(heap2.max_value) # 7

You can look up and delete arbitrary elements in $O(log(n))$ time.

del heap2[6]
print(6 in heap2) # False

Iteration is performed out of order. Note that this order is also not the order in which the elements are stored in the heap!

print(list(heap2)) # [5, 0, 4, 1, 2, 9, 8, 7]

Metadata

Release files for heap-mapping 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for heap-mapping 0.2.0
File Size Uploaded Provenance Actions
heap_mapping-0.2.0.tar.gz 8.0 kB With provenance Details for heap_mapping-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for heap-mapping 0.2.0
File Interpreter ABI Platform Actions
heap_mapping-0.2.0-py3-none-any.whl Python 3 none any Details for heap_mapping-0.2.0-py3-none-any.whl

Total release size: 14.2 kB

Release files / heap_mapping-0.2.0.tar.gz

Download URL heap_mapping-0.2.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d1d2f25688d9610b605b9ab381e3981809393d6e4ec9f153971aed6bb9175860
BLAKE2b-256 checksum
How to use checksums
e0de71eb454e23dcf6b4ff53a952616e5f0ba61102a7f0d7fe08b37725193787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 5, 2026.

Transparency log

Release files / heap_mapping-0.2.0-py3-none-any.whl

Download URL heap_mapping-0.2.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c30e19a5983736a5f0fa3a509e447d7aff17d9a3e6e032485cc77df941c628c4
BLAKE2b-256 checksum
How to use checksums
8804e2283f85b39e73f95e7182a591a6cc69c45121ae9855810ba78378c700f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 5, 2026.

Transparency log

Security for heap-mapping 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for heap_mapping-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page