{"id":15490546,"url":"https://github.com/theodesp/go-shuffled-queue","last_synced_at":"2025-04-22T19:10:05.998Z","repository":{"id":97066537,"uuid":"92856076","full_name":"theodesp/go-shuffled-queue","owner":"theodesp","description":"A priority queue that shuffles elements with the same priority. Written in Go and inspired by https://github.com/mafintosh/shuffled-priority-queue.","archived":false,"fork":false,"pushed_at":"2018-10-09T09:33:20.000Z","size":20,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T19:09:59.800Z","etag":null,"topics":["golang","priority-queue","queue","random","set"],"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/theodesp.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":"2017-05-30T16:57:30.000Z","updated_at":"2021-06-06T06:38:02.000Z","dependencies_parsed_at":"2023-04-22T21:37:46.222Z","dependency_job_id":null,"html_url":"https://github.com/theodesp/go-shuffled-queue","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/theodesp%2Fgo-shuffled-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-shuffled-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-shuffled-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-shuffled-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/go-shuffled-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250306638,"owners_count":21408926,"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":["golang","priority-queue","queue","random","set"],"created_at":"2024-10-02T07:22:02.961Z","updated_at":"2025-04-22T19:10:05.962Z","avatar_url":"https://github.com/theodesp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-shuffled-queue\nA priority queue that shuffles elements with the same priority written in Go \nand inspired by [shuffled-priority-queue](https://github.com/mafintosh/shuffled-priority-queue).\n\n## Install\n\n`$ go get -u github.com/theodesp/go-shuffled-queue`\n\n## Usage\n```go\nqueue := shuffledQueue.NewSPQ()\n\nqueue.Add(\"hello\") // Default Priority is 0\nqueue.Add(\"world\") // Default Priority is 0\n\nqueue.AddWithPriority(\"welt\", 1)\nqueue.AddWithPriority(\"verden\", 2)\nqueue.AddWithPriority(\"verden\", 3)\n\n\nfmt.Println(queue.Pop()) // returns \"verden\", true\nfmt.Println(queue.Pop()) // returns \"verden\", true\nfmt.Println(queue.Pop()) // returns \"welt\", true\nfmt.Println(queue.Pop()) // returns \"hello\", true or \"world\", true\nfmt.Println(queue.Pop()) // returns \"hello\", true or \"world\", true\nfmt.Println(queue.Pop()) // returns nil, false\n\n```\n\n\n## API\n\n#### `queue := shuffledQueue.NewSPQ()`\nCreate a new queue.\n\n\n#### `value := queue.Add(value)`\n\nAdd a new value to the queue. Accepts single values. The value is returned for convenience. It also assigns it with a default priority.\n\n#### `value := queue.AddWithPriority(value)`\n\nAdd a new PriorityQueueItem to the queue. The value is returned for convenience.\n\n\n#### `value := queue.Remove(value)`\n\nRemove a value from the queue.\n\n\n#### `value := queue.Pop()`\n\nPop the value with the highest priority off the queue. If multiple values have the same priority a random one is popped.\nIf the queue is empty it will return a value of nil.\n\n#### `value := queue.Last()`\n\nSame as Pop() but does not mutate the queue.\n\n#### `value := queue.Shift()`\n\nSame as Pop() but returns a value with the lowest priority.\n\n#### `value := queue.First()`\n\nSame as Shift() but does not mutate the queue.\n\n\n## Licence\nMIT @ 2017\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-shuffled-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Fgo-shuffled-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-shuffled-queue/lists"}