{"id":17299889,"url":"https://github.com/twmb/go-mmheap","last_synced_at":"2025-03-26T22:13:33.439Z","repository":{"id":57607724,"uuid":"202492617","full_name":"twmb/go-mmheap","owner":"twmb","description":"A min-max heap in Go.","archived":false,"fork":false,"pushed_at":"2019-08-15T10:03:55.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T03:43:01.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/twmb.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}},"created_at":"2019-08-15T07:12:53.000Z","updated_at":"2019-08-15T10:03:42.000Z","dependencies_parsed_at":"2022-08-30T04:42:24.328Z","dependency_job_id":null,"html_url":"https://github.com/twmb/go-mmheap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twmb%2Fgo-mmheap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twmb%2Fgo-mmheap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twmb%2Fgo-mmheap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twmb%2Fgo-mmheap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twmb","download_url":"https://codeload.github.com/twmb/go-mmheap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245743434,"owners_count":20665092,"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","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":[],"created_at":"2024-10-15T11:24:23.340Z","updated_at":"2025-03-26T22:13:33.407Z","avatar_url":"https://github.com/twmb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-mmheap\n=========\n\nPackage `mmheap` provides a drop-in min-max heap for any type that implements\nheap.Interface.\n\nIn a min-max heap, the minimum element is at the root at index 0, and the\nmaximum element is in one of the two root children.\n\nThus, a min-max heap provides an efficient way to access either the minimum or\nmaximum elements in a set in O(1) time.\n\nDue to the increased number of comparisons to implement a min-heap, its runtime\nis slower than a general heap (in this implementation, just under 2x). Because\nof this, unless you need to continually access both the minimum and maximum\nelements, it may be beneficial to use a different data structure. Even if you\ndo need to continually access the minimum or maximum, a different data\nstructure may be better.\n\nThis package exists for anybody looking, but I recommend benchmarking this\nagainst a\n[btree](github.com/google/btree).\nGenerally, a btree is a good and fast data structure.\nHowever, a key benefit of `heap` or `mmheap` is the ability to\nmodify elements and fix their position in the tree.\n\nFor more information about a min-max heap, read\n[this](http://www.cs.otago.ac.nz/staffpriv/mike/Papers/MinMaxHeaps/MinMaxHeaps.pdf)\npaper.\n\nAll of the tests are taken from the stdlib's `container/heap package and the Go\nBSD license is copied into `mmheap_test.go` for completeness. As well, the main\npackage-level functions are duplicated, but mostly because there is basically\none way to write Push/Pop on a heap. The sift up and sift down functions are\nnew. This repo itself is MIT.\n\nDocumentation\n-------------\n\n[![GoDoc](https://godoc.org/github.com/twmb/go-mmheap?status.svg)](https://godoc.org/github.com/twmb/go-mmheap)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwmb%2Fgo-mmheap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwmb%2Fgo-mmheap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwmb%2Fgo-mmheap/lists"}