Maxheap
Project description
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
Project details
Release history Release notifications | RSS feed
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 maxheapq-0.0.4.tar.gz.
File metadata
- Download URL: maxheapq-0.0.4.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ebd351889b06eb36629de9d6daf588ff6c6d0726492c332bc67dd36eb6664d0
|
|
| MD5 |
07a9b8c504c9cdd46edf690e35ac5672
|
|
| BLAKE2b-256 |
da316de9ca4b9fd2d274d36b5eeb3dd44c7a68ec4657dadea04a0b53710fe75c
|
File details
Details for the file maxheapq-0.0.4-py3-none-any.whl.
File metadata
- Download URL: maxheapq-0.0.4-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e43af6922997b251907b8cdca7383e393066d40d27738142a6a7370be4f54f4
|
|
| MD5 |
f86f6f230d5973efe04f8fcfff7eb7cd
|
|
| BLAKE2b-256 |
e5a1199b7b1126500ed323960f29e05ade9d0826d2d4e9a8d420367283776b35
|