Skip to main content

Tree Containers -- PriorityMap, PrioritySet, TreeMap

Project description

Tree Containers

Asymptotically-efficient tree-based containers in pure Python. Licensed under the Apache License Version 2.0.

Priority Map

A combination between a heap and a map that stores key:priority mappings.

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

PrioritySet

To be implemented.

TreeMap

To be implemented.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treecontainers-0.0.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

treecontainers-0.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file treecontainers-0.0.1.tar.gz.

File metadata

  • Download URL: treecontainers-0.0.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for treecontainers-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c51e4cffcd06fa55169a81fa3bdb9ad48dd74055b5e0fa27785dffe3bc0e9730
MD5 fec46471c89862cae684f5ef07fa53a0
BLAKE2b-256 ce672f40d47efe044fbc21a94ec34929424374692a7c3106d8428eac4ad6e1d6

See more details on using hashes here.

File details

Details for the file treecontainers-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: treecontainers-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for treecontainers-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac9ddb67c571fa5b5bd1c3e6b1113cab6232aff97ec0bd314a17cc3d19b9eb8c
MD5 1aca7c36b58e0f55e2fef7fabca4724b
BLAKE2b-256 4419e5b23e0bd1903a1b307a7fdf7a1bd5f14816cb4009d2e4368ffc1a0d62b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page