🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

prioritymap

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prioritymap

Priority Map -- efficient heap x map

0.0.2
PyPI
Maintainers
1

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

OperationDescriptionRuntime Complexity
__getitem__(key)Get priority of keyO(1)
__setitem__(key, priority)Set priority of keyO(log n)
__delitem__(key)Remove a keyO(log n)
__contains__(key)Check whether a key is containedO(1)
__len__()Return the number of keys containedO(1)
peek()Get lowest-priority key and its priorityO(1)
pop()Get and remove lowest-priority key and its priorityO(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

FAQs

Did you know?

Socket

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.

Install

Related posts