{"id":20993125,"url":"https://github.com/revzim/azhpq","last_synced_at":"2025-03-13T12:41:19.396Z","repository":{"id":57623701,"uuid":"397300785","full_name":"revzim/azhpq","owner":"revzim","description":"simple, quick, \u0026 lightweight golang heap priority queue with zero dependencies","archived":false,"fork":false,"pushed_at":"2021-08-18T16:22:08.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T08:02:17.414Z","etag":null,"topics":["binary-heap","go","golang","heap-priority-queue","lightweight","zero-dependency"],"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/revzim.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":"2021-08-17T15:11:56.000Z","updated_at":"2021-08-18T16:22:11.000Z","dependencies_parsed_at":"2022-08-30T11:41:26.529Z","dependency_job_id":null,"html_url":"https://github.com/revzim/azhpq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revzim%2Fazhpq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revzim%2Fazhpq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revzim%2Fazhpq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revzim%2Fazhpq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revzim","download_url":"https://codeload.github.com/revzim/azhpq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243410233,"owners_count":20286387,"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":["binary-heap","go","golang","heap-priority-queue","lightweight","zero-dependency"],"created_at":"2024-11-19T07:13:48.653Z","updated_at":"2025-03-13T12:41:19.331Z","avatar_url":"https://github.com/revzim.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# azhpq\r\n\r\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/revzim/azhpq)](https://pkg.go.dev/github.com/revzim/azhpq)\r\n[![Go Report Card](https://goreportcard.com/badge/github.com/revzim/azhpq)](https://goreportcard.com/report/github.com/revzim/azhpq)\r\n\r\n## golang heap priority queue\r\n- simple, quick, \u0026 lightweight\r\n- zero dependencies\r\n\r\n## USE:\r\n```\r\n  hpq := New()\r\n\r\n  qn1 := \u0026QueueNode{\r\n    Value:    \"andy\",\r\n    Priority: 1,\r\n  }\r\n\r\n  qn2 := \u0026QueueNode{\r\n    Value:    \"john\",\r\n    Priority: 2,\r\n  }\r\n\r\n  qn3 := \u0026QueueNode{\r\n    Value:    \"jim\",\r\n    Priority: 5,\r\n  }\r\n  \r\n  hpq.Add(qn1)\r\n  hpq.Add(qn2) \r\n  hpq.Add(qn3)\r\n  // OR\r\n  hpq.AddMany(qn1, qn2, qn3)\r\n\r\n  hpq.ForEach(func (qn *QueueNode, i int) {\r\n    log.Println(fmt.Sprintf(\"%d ==\u003e %+v\", i, qn))\r\n  })\r\n\r\n  // OUT: \r\n  // 0 ==\u003e \u0026{Value:jim Priority:5}\r\n  // 1 ==\u003e \u0026{Value:john Priority:2}\r\n  // 2 ==\u003e \u0026{Value:andy Priority:1}\r\n\r\n  highestPrioNode := hpq.Poll()\r\n  log.Println(fmt.Sprintf(\"removed highest prio node: %s\", highestPrioNode.Value))\r\n\r\n  // OUT: \r\n  // removed highest prio node: jim\r\n\r\n  hpq.ForEach(func (qn *QueueNode, i int) {\r\n    log.Println(fmt.Sprintf(\"%d ==\u003e %+v\", i, qn))\r\n  })\r\n\r\n  // OUT: \r\n  // 0 ==\u003e \u0026{Value:john Priority:2}\r\n  // 1 ==\u003e \u0026{Value:andy Priority:1}\r\n```\r\n\r\n## TEST:\r\n- `go test -v -run TestHPQ azhpq.go azhpq_test.go`\r\n```\r\n  === RUN   TestHPQ\r\n  2021/08/17 10:54:59 0 ==\u003e \u0026{Value:jim Priority:5}\r\n  2021/08/17 10:54:59 1 ==\u003e \u0026{Value:john Priority:2}\r\n  2021/08/17 10:54:59 2 ==\u003e \u0026{Value:andy Priority:1}\r\n  2021/08/17 10:54:59 0 ==\u003e \u0026{Value:jim Priority:7}\r\n  2021/08/17 10:54:59 1 ==\u003e \u0026{Value:john Priority:4}\r\n  2021/08/17 10:54:59 2 ==\u003e \u0026{Value:andy Priority:3}\r\n  2021/08/17 10:54:59 removed highest prio node: jim\r\n  2021/08/17 10:54:59 0 ==\u003e \u0026{Value:john Priority:4}\r\n  2021/08/17 10:54:59 1 ==\u003e \u0026{Value:andy Priority:3}\r\n  --- PASS: TestHPQ (0.00s)\r\n  ok      command-line-arguments  0.138s\r\n```\r\n\r\n## AUTHOR:\r\n- [revzim](https://github.com/revzim)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevzim%2Fazhpq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevzim%2Fazhpq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevzim%2Fazhpq/lists"}