BHPQ - Binary Heap Priority Queue
A binary heap priority queue implementation, thread safe
Installation
You can install bhpq from PyPI:
pip install bhpq
bhpq is supported on Python 3.7
Usage
from bhpq import BinaryHeapPriorityQueue
# The BinaryHeapPriorityQueue constructor takes two input params:
# - prefer (required param)
# the preferred object is pushed to the top of the queue
# the prefer input is a lambda function eg:
# prefer=(lambda lhs, rhs: lhs if lhs.val >= rhs.val else rhs)
# - size
# The initial size allocation of the queue, default value is 10
Example
class Node(object):
def __init__(self, val):
self.val = val
A = BinaryHeapPriorityQueue(
prefer=(lambda lhs, rhs: lhs if lhs.val >= rhs.val else rhs), size=5
)
A.add(Node(1))
A.add(Node(4))
A.add(Node(3))
A.add(Node(5))
A.add(Node(2))
assert 5 == A.pop().val
assert 4 == A.pop().val
assert 3 == A.pop().val
assert 2 == A.pop().val
assert 1 == A.pop().val
assert None == A.pop()
Methods
size()
returns the current size of the priority queue
peek()
returns the object at the topof the priority queue if it exists else returns None
pop()
removes and returns the object at the top of the priority queue if it exists else returns None
add(val)
adds an element to the priority queue
Maintainer
Metadata
Release files for bhpq 2.0.1
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 |
|---|---|---|---|---|
| bhpq-2.0.1.tar.gz | 3.0 kB | Without provenance | Details for bhpq-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bhpq-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for bhpq-2.0.1-py3-none-any.whl |
Total release size: 7.1 kB
Release files / bhpq-2.0.1.tar.gz
| Download URL | bhpq-2.0.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03bd7d93e8e442dec2c789944825d5df4a5f5ce0d16d999b3df02ceccff28de2
|
|
BLAKE2b-256 checksum How to use checksums |
101d6e922bf14474e430041f39a3068836915d8931275bd260806fe1e19d0b87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / bhpq-2.0.1-py3-none-any.whl
| Download URL | bhpq-2.0.1-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91526b9feb7714542a71f55b10bd3de9c5d6726a3d5a4efdbc439641660f0236
|
|
BLAKE2b-256 checksum How to use checksums |
3efdf17e933271fb6332ab225681322c064be561507f84ec8bf66265428cc5ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for bhpq 2.0.1
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.