{"id":42988861,"url":"https://github.com/webbmaffian/go-prio-queue","last_synced_at":"2026-01-31T02:34:17.347Z","repository":{"id":61623816,"uuid":"537129680","full_name":"webbmaffian/go-prio-queue","owner":"webbmaffian","description":"Zero-allocation priority queue for Golang.","archived":false,"fork":false,"pushed_at":"2023-01-05T09:58:58.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-20T10:04:29.382Z","etag":null,"topics":["go","golang","priority-queue","zero-allocation"],"latest_commit_sha":null,"homepage":"","language":"Go","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/webbmaffian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-15T17:11:26.000Z","updated_at":"2024-06-20T10:04:29.383Z","dependencies_parsed_at":"2023-02-04T00:00:25.088Z","dependency_job_id":null,"html_url":"https://github.com/webbmaffian/go-prio-queue","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/webbmaffian/go-prio-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbmaffian%2Fgo-prio-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbmaffian%2Fgo-prio-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbmaffian%2Fgo-prio-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbmaffian%2Fgo-prio-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webbmaffian","download_url":"https://codeload.github.com/webbmaffian/go-prio-queue/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbmaffian%2Fgo-prio-queue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28927244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T22:32:35.345Z","status":"online","status_checked_at":"2026-01-31T02:00:09.179Z","response_time":128,"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":["go","golang","priority-queue","zero-allocation"],"created_at":"2026-01-31T02:34:17.290Z","updated_at":"2026-01-31T02:34:17.342Z","avatar_url":"https://github.com/webbmaffian.png","language":"Go","readme":"# Go Prio Queue\nA highly optimized [priority queue](https://en.wikipedia.org/wiki/Priority_queue) with generics. See [benchmark](#benchmark).\n- Support for min, max and custom priority comparator.\n- 100% Go.\n- Zero dependencies.\n- Zero allocations for push/pop operations.\n- Around 3 ns for push (up to 4000 values).\n- Around 2 ns for pop.\n\n## Install\n```\ngo get github.com/webbmaffian/go-prio-queue\n```\n\n## Usage\n\n### Min (ascending) priority queue\n```go\nq := NewMinQueue[string, float64]()\n\nq.Push(\"a\", 56)\nq.Push(\"b\", 12)\nq.Push(\"c\", 34)\n\nfor !q.Empty() {\n    log.Println(q.Pop())\n}\n\n// b 12\n// c 34\n// a 56\n```\n\n### Max (descending) priority queue\n```go\nq := NewMaxQueue[string, float64]()\n\nq.Push(\"a\", 56)\nq.Push(\"b\", 12)\nq.Push(\"c\", 34)\n\nfor !q.Empty() {\n    log.Println(q.Pop())\n}\n\n// a 56\n// c 34\n// b 12\n```\n\n### Priority queue with custom comparator\nThe `compare` function should return `true` if `a` has higher priority than `b`.\n```go\n// Prioritize even numbers\nfunc compare(a, b float64) bool {\n    if a % 2 == 0 \u0026\u0026 b % 2 == 1 {\n        return true\n    }\n\n    return a \u003c b\n}\n\nq := NewQueue[string, float64](compare)\n\nq.Push(\"a\", 1)\nq.Push(\"b\", 2)\nq.Push(\"c\", 3)\nq.Push(\"d\", 4)\nq.Push(\"e\", 5)\n\nfor !q.Empty() {\n    log.Println(q.Pop())\n}\n\n// b 2\n// d 4\n// a 1\n// c 3\n// e 5\n```\n\n## Benchmark\n```\ngoos: darwin\ngoarch: arm64\npkg: github.com/webbmaffian/go-prio-queue\nBenchmarkSmallQueueNew/255-10                 4459081           269.000 ns/op        2688 B/op           1 allocs/op\nBenchmarkSmallQueuePush/255-10              349781355             3.427 ns/op           0 B/op           0 allocs/op\nBenchmarkSmallQueuePop/255-10               586978732             2.041 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueueNew/16-10                14742232            75.690 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/32-10                15763598            75.530 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/64-10                15500386            75.620 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/128-10               16165234            75.990 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/256-10               15374652            75.800 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/512-10               16020327            76.480 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/1024-10              15808869            76.040 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/2048-10              15815224            76.110 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/4096-10              14650374            75.960 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/8192-10              16067761            76.890 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueueNew/16384-10             16040492            78.120 ns/op         240 B/op           3 allocs/op\nBenchmarkCustomQueuePush/16-10              441543746             2.720 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/32-10              438644319             2.734 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/64-10              433402447             2.770 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/128-10             427948100             2.806 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/256-10             429108579             2.770 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/512-10             427958403             2.761 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/1024-10            389328944             2.797 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/2048-10            386863712             2.961 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/4096-10            298121041             3.472 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/8192-10             58608999            17.650 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePush/16384-10              114636         11915.000 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/16-10               573327946             2.063 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/32-10               583133943             2.043 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/64-10               581798670             2.059 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/128-10              583278972             2.049 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/256-10              581352746             2.062 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/512-10              582200670             2.056 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/1024-10             577774112             2.056 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/2048-10             578327653             2.057 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/4096-10             583535660             2.059 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/8192-10             584634346             2.062 ns/op           0 B/op           0 allocs/op\nBenchmarkCustomQueuePop/16384-10            583455508             2.061 ns/op           0 B/op           0 allocs/op\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebbmaffian%2Fgo-prio-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebbmaffian%2Fgo-prio-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebbmaffian%2Fgo-prio-queue/lists"}