{"id":21452952,"url":"https://github.com/arindas/bheap","last_synced_at":"2025-08-13T02:41:13.919Z","repository":{"id":122069652,"uuid":"415963050","full_name":"arindas/bheap","owner":"arindas","description":"A generic binary max heap for implementing a dynamically prioritizable priority queue.","archived":false,"fork":false,"pushed_at":"2021-10-20T11:33:46.000Z","size":1843,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-15T02:34:20.605Z","etag":null,"topics":["binary-heap"],"latest_commit_sha":null,"homepage":"https://arindas.github.io/bheap/bheap/index.html","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arindas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-11T14:30:52.000Z","updated_at":"2025-02-20T00:10:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"de19e67f-fc78-4be6-99dd-ca5a2e5cf736","html_url":"https://github.com/arindas/bheap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/arindas/bheap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindas%2Fbheap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindas%2Fbheap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindas%2Fbheap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindas%2Fbheap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arindas","download_url":"https://codeload.github.com/arindas/bheap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindas%2Fbheap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270169752,"owners_count":24539289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-heap"],"created_at":"2024-11-23T04:33:21.556Z","updated_at":"2025-08-13T02:41:13.896Z","avatar_url":"https://github.com/arindas.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bheap\n[![ci-tests](https://github.com/arindas/bheap/actions/workflows/ci-tests.yml/badge.svg)](https://github.com/arindas/bheap/actions/workflows/ci-tests.yml)\n[![rustdoc](https://github.com/arindas/bheap/actions/workflows/rustdoc.yml/badge.svg)](https://github.com/arindas/bheap/actions/workflows/rustdoc.yml)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Farindas%2Fbheap.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Farindas%2Fbheap?ref=badge_shield)\n\nA generic binary max heap implementation for implementing a dynamically prioritizable priority queue.\n\nThis implementation uses a vector as the underlying data-structure. Hence, there is no oppurtunity\nfor fine grained locking. Users of this crate are request to wrap `bheap::BinaryMaxHeap` with the\nrequired concurrency primitive for use in multithreaded contexts.\n\n## Why is this necessary?\nThe binary heap implementation provided by the standard library (`use std::collections::binary_heap::BinaryHeap;`),\nassumes that the ordering of the elements in the domain is fixed. I needed a binary heap implementation which allowed\nfor change in ordering of elements at runtime.\n\n## How does it work?\n`bheap::BinaryMaxHeap` enforces the `Ord + bheap::Uid` trait bounds on the element type. The `Uid` trait, simply\npresents a method for returing a unique `u64` uid for the type.\n\nThe struct maintains a `Vec\u003cT\u003e` as the underlying storage buffer and a `HashMap\u003cu64, usize\u003e` for maintaining a\nmapping from `T::uid()` to position in vector. This map is updated on every heap operation to remain consistent.\n\nWhen the ordering of an element changes, its position in the heap can be looked up in the heap using the\nhashmap. Then, we `heapify_up()` or `heapify_down()` as required to restore heap property.\n\n## Limitations\nSince, we use `u64` for uniquely identitfying elements, this heap can only scale up `2^64 = 18446744073709551616` elements.\nThis was more than enough for my purposes.\n\nAnother interesting property of this library is that it has no third party dependencies other than the standard libary.\n\n# License\n\n`bheap` is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Farindas%2Fbheap.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Farindas%2Fbheap?ref=badge_large)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farindas%2Fbheap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farindas%2Fbheap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farindas%2Fbheap/lists"}