Monotone priority queue useful for shortest paths and more; wraps Rust's radix-heap crate
Project description
Radix Heap for Python
This module provides a Python implementation of Radix Heap-like data structures, designed to function as monotone priority queues. The heavy-lifting for the heap operations is powered by the radix-heap
Rust crate from mpdn -- they did 99% of the hard work by implementing the data structure.
Monotone priority queues are useful for pathfinding in general (e.g., A*, Dijkstra's algorithm). A monotone priority queue must maintain the invariant where the extracted elements form a monotone sequence (e.g., for a max-heap, the extracted elements are in non-increasing order).
Overview
A Radix Heap is a type of priority queue where the extracted elements form a monotone sequence. This module includes implementations for both maximum and minimum heaps for integer and float keys.
Classes
RadixHeapLike[K, V]
: A generic base class for Radix Heap-like structures.RadixMaxHeapInt[V]
: A radix max heap for integers.RadixMinHeapInt[V]
: A radix min heap for integers.RadixMaxHeap[V]
: A radix max heap for floats (or integers).RadixMinHeap[V]
: A radix min heap for floats (or integers).
Methods
push(key: K, value: V) -> None
: Adds a key-value pair to the heap.pop() -> V
: Removes and returns the minimum value from the heap.pop_with_key() -> tuple[K, V]
: Removes and returns the minimum key-value pair from the heap.top() -> V | None
: Returns the minimum value from the heap without removing it.clear() -> None
: Removes all elements from the heap.__len__() -> int
: Returns the number of elements in the heap.
Usage Examples
Radix Max Heap for Integers
from radix_heap import RadixMaxHeapInt
heap = RadixMaxHeapInt()
heap.push(10, "A")
heap.push(5, "B")
heap.push(8, "C")
while heap:
print(heap.pop())
# Output: "A", "C", "B"
Installation
To install the module, you can use pip:
pip install radix-heap
Contributing
Contributions are welcome! Please check the repository and feel free to open issues or submit pull requests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file radix_heap-0.1.0.tar.gz
.
File metadata
- Download URL: radix_heap-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ece9260a6c5b0161c54d04a17b7bbf623947fd14faaac0f8d24f2a4e69ade0c6 |
|
MD5 | 62d15fa30744223e79c18288120b688b |
|
BLAKE2b-256 | 436de7aad8563c4a1138475a49a388eb2191373d51cfb873188648efe5fa8689 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 139.1 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a7e642c92cbdf954c44d9ec45eb7a6a2c10034b25c120afc91863ce0d8ed6f0 |
|
MD5 | bbe4c7e68973b20a6e23e99c5cc4fda2 |
|
BLAKE2b-256 | f422fc5275c5001492a36ed12add6e91f3f1c0bb2ea8576af64518c9fb53132c |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-win32.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-win32.whl
- Upload date:
- Size: 132.7 kB
- Tags: CPython 3.7+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41815da74a8961f992536375e65c2eed131912864a98c09799903a02c850690d |
|
MD5 | 132b9a1a0bca06b81e4a395ecd97d89b |
|
BLAKE2b-256 | b71de96499593fb5f4dcd9e677123b6e86da882107b2ca6d56ff841e30a4e9f6 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 441.7 kB
- Tags: CPython 3.7+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8cfd135a2d9f1a9f8ace7be18bebdcc4cb770264131ae7365ae8e3d32795a76 |
|
MD5 | 79c6f24cb6a9e5585571666e3d59882f |
|
BLAKE2b-256 | 105e4cf74b6490a63902343f9ae42c17095f83052b6457317904482949f19137 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-musllinux_1_2_i686.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 463.5 kB
- Tags: CPython 3.7+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cb61593269f369d975dc61a305f605142b9f311911c6857464fab8861e6a185 |
|
MD5 | 6e9bfba75ee5ee335a68e6ec63941fe2 |
|
BLAKE2b-256 | 6bbfe06b61787d8fdfc3883297a9048187002a670b38e319e2120699b863d760 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-musllinux_1_2_armv7l.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 541.3 kB
- Tags: CPython 3.7+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 023008b292de0112f141be04f822df1be5dea71818926eacdfa387b628c1793d |
|
MD5 | 7a4941b9b13b1738718334d4da342f47 |
|
BLAKE2b-256 | 90a404e9cbca39533c1623c8e737fcbc5fcc7502c0f678a4cb1959c801c71cbe |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 459.6 kB
- Tags: CPython 3.7+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a97a2253d9639201597f5ad2d1e6f6c7fac51d86331833b6fe92c1f04ee4f4 |
|
MD5 | 0f2b1f0e57f487360d50675ae252cfe2 |
|
BLAKE2b-256 | 15b92957e2c88d069f1a4b08bb29f275de1823c8ea9e7cf685127951be21530b |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 272.0 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1aa67c08474c47d281c566022d0cf77695b481cb8059047e51f94a59457a5cf |
|
MD5 | 3c8137bc454ab7dd7406271518f71f14 |
|
BLAKE2b-256 | db4d6c36cdc7b6e10e9ca428b6803e9034d150151f130925968be30cab13272b |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 331.1 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f520a1ec13a8729cb0f062435d480abd08995ea075dc1bb3c8e262115998ff99 |
|
MD5 | 8f8a1e0f349eb2fa8b1b46f1ec3989a1 |
|
BLAKE2b-256 | e5bc2ad7fa4eaba92299b01673d7fdf38b4b42d5e410e81f2a9222e7c9d9e655 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 308.5 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 332b43cf9c9619eabade1af1d374d055972168947b07ad877a6e7e0159b5ab13 |
|
MD5 | e0181ed7d26f06541f05bd6f52eed7dc |
|
BLAKE2b-256 | 13878c0502983b10752b2e7f5284bfdbf93fc207c03002b61b0cdf3703e02561 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 278.4 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 128174dcd508f8dea1bad95a118f1c6f31c0910654c38d60057615419696c75e |
|
MD5 | bf26ae35114174f188203d2d674d94cc |
|
BLAKE2b-256 | 42a53d808262aa2dab5455c64ca6c4782d8c8820c05fa27028fe612499b13b83 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 281.1 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ce24a9637a3341b2c38f7a10674ca0abdadfd33d52953e732b73bd9a567a374 |
|
MD5 | f2960471a73f4b0b7b88e05dfa7c22e0 |
|
BLAKE2b-256 | 61edb67d35f81c1f1227060deec7dc3ce481b1d1f4bb2af435669abcb273d840 |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 282.7 kB
- Tags: CPython 3.7+, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 983952dc47648317d929ef7627342b301dc14784520ccb433716227cac9c03ea |
|
MD5 | 98d1ad8634fdd4f286883927ba992fda |
|
BLAKE2b-256 | c382db8203db951af9deedc9036cfceaa32f28ecf2250f33b103d94bc88bb98f |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 236.2 kB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce18ead1ce096a81b3aa13b0a99a02222ec40a0a39d2f53642f9f494d78ecf8b |
|
MD5 | 6b667e574f348f55a80eec88c4e2be74 |
|
BLAKE2b-256 | 7746ba3e6980a1143efcd66dde8205ebd1faadde60575a3e976b2db8a09c95fe |
File details
Details for the file radix_heap-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: radix_heap-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 238.0 kB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 242369c471d8db4a74a47ea05dbaa4214e586fabce201f96fc33473093025a16 |
|
MD5 | f40cc3be2c58823c588e0d000e1d86e0 |
|
BLAKE2b-256 | 991323fa2c4dd5219c8f43eadc0dc7b1ead356a3ff021fbe27a8281719cbc776 |