maxheap
Existing heapq library can be used as a maxheap by negating the values passed We need to negate back while retrieving from the heap as well. This can result in a cumbersome interface.
Maxpheap is a implementation similar to heapq that lets you push and pop to the heap. In a maxheap largest element has the priority.
Dependencies
Python3
Install
pip3 install maxheap
Verify install
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import maxheap
Usage
heap = [] # creates an empty heap
heappush(heap, item) # pushes a new item on the heap
item = heappop(heap) # pops the largest item from the heap
item = heap[0] # largest item on the heap without popping it
heapify(x) # transforms list into a max heap, in-place, in linear time
item = heapreplace(heap, item) # pops and returns largest item, and adds
# new item; the heap size is unchanged
Metadata
Release files for maxheapq 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| maxheapq-0.0.4.tar.gz | 8.6 kB | Without provenance | Details for maxheapq-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maxheapq-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for maxheapq-0.0.4-py3-none-any.whl |
Total release size: 17.1 kB
Release files / maxheapq-0.0.4.tar.gz
| Download URL | maxheapq-0.0.4.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ebd351889b06eb36629de9d6daf588ff6c6d0726492c332bc67dd36eb6664d0
|
|
BLAKE2b-256 checksum How to use checksums |
da316de9ca4b9fd2d274d36b5eeb3dd44c7a68ec4657dadea04a0b53710fe75c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / maxheapq-0.0.4-py3-none-any.whl
| Download URL | maxheapq-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e43af6922997b251907b8cdca7383e393066d40d27738142a6a7370be4f54f4
|
|
BLAKE2b-256 checksum How to use checksums |
e5a1199b7b1126500ed323960f29e05ade9d0826d2d4e9a8d420367283776b35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for maxheapq 0.0.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.