Python Priority Map
A asymptotically-efficient combination between a heap and a map that stores key:priority mappings. Licensed under the Apache License Version 2.0.
Operations
| Operation | Description | Runtime Complexity |
|---|---|---|
__getitem__(key) |
Get priority of key | O(1) |
__setitem__(key, priority) |
Set priority of key | O(log n) |
__delitem__(key) |
Remove a key | O(log n) |
__contains__(key) |
Check whether a key is contained | O(1) |
__len__() |
Return the number of keys contained | O(1) |
peek() |
Get lowest-priority key and its priority | O(1) |
pop() |
Get and remove lowest-priority key and its priority | O(log n) |
Example Console Output
>>> from prioritymap import PriorityMap
>>> pm = PriorityMap()
>>> pm["first"] = 1
>>> pm["second"] = 2
>>> pm["underdog"] = 5
>>> pm.peek()
('first', 1)
>>> pm["underdog"] = 0
>>> len(pm)
3
>>> pm.pop()
('underdog', 0)
>>> pm.pop()
('first', 1)
>>> pm.pop()
('second', 2)
>>> len(pm)
0
Metadata
Release files for prioritymap 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| prioritymap-0.0.2.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prioritymap-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / prioritymap-0.0.2.tar.gz
| Download URL | prioritymap-0.0.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50bd454fc1c6b64be8e66b9c4ac37532ff33d1719bea252532f9570c870dcbb8
|
|
BLAKE2b-256 checksum How to use checksums |
b5f3c22bcd2c168d14555d52e6f6cfa72595ab1cab1ebf4098ff4f4cd357a60f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
|
Release files / prioritymap-0.0.2-py3-none-any.whl
| Download URL | prioritymap-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a2de9f28590d7bd95602c3edb55ef90569dce1bb40b7f2aac2b9223db0944a7
|
|
BLAKE2b-256 checksum How to use checksums |
6bb1ed6e38c89e3d82a46cdecf9b76b718f9121ddf017d52fab778c4c9bc2f6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
|