
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A binary heap priority queue implementation, thread safe
You can install bhpq from PyPI:
pip install bhpq
bhpq is supported on Python 3.7
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
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()
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
FAQs
Binary Heap Priority Queue
We found that bhpq demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.