{"id":20761692,"url":"https://github.com/s0rg/set","last_synced_at":"2026-02-28T09:32:00.497Z","repository":{"id":64298032,"uuid":"566002998","full_name":"s0rg/set","owner":"s0rg","description":"generic set","archived":false,"fork":false,"pushed_at":"2025-04-25T10:47:05.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-27T03:58:22.580Z","etag":null,"topics":["data-structures","generics","golang","ordered-set","unordered-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/s0rg.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,"zenodo":null}},"created_at":"2022-11-14T19:18:34.000Z","updated_at":"2026-02-18T16:11:56.000Z","dependencies_parsed_at":"2024-08-26T23:43:45.971Z","dependency_job_id":"3586f332-7510-4216-92fd-2683a95bef93","html_url":"https://github.com/s0rg/set","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/s0rg/set","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s0rg","download_url":"https://codeload.github.com/s0rg/set/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29929350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"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":["data-structures","generics","golang","ordered-set","unordered-set"],"created_at":"2024-11-17T10:25:18.560Z","updated_at":"2026-02-28T09:32:00.479Z","avatar_url":"https://github.com/s0rg.png","language":"Go","readme":"[![PkgGoDev](https://pkg.go.dev/badge/github.com/s0rg/set)](https://pkg.go.dev/github.com/s0rg/set)\n[![License](https://img.shields.io/github/license/s0rg/set)](https://github.com/s0rg/set/blob/master/LICENSE)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/s0rg/set)](go.mod)\n[![Tag](https://img.shields.io/github/v/tag/s0rg/set?sort=semver)](https://github.com/s0rg/set/tags)\n\n[![CI](https://github.com/s0rg/set/workflows/ci/badge.svg)](https://github.com/s0rg/set/actions?query=workflow%3Aci)\n[![Go Report Card](https://goreportcard.com/badge/github.com/s0rg/set)](https://goreportcard.com/report/github.com/s0rg/set)\n[![Maintainability](https://qlty.sh/badges/06d50a96-bbc8-4635-9f48-83ea9fdf548b/maintainability.svg)](https://qlty.sh/gh/s0rg/projects/set)\n[![Code Coverage](https://qlty.sh/badges/06d50a96-bbc8-4635-9f48-83ea9fdf548b/test_coverage.svg)](https://qlty.sh/gh/s0rg/projects/set)\n![Issues](https://img.shields.io/github/issues/s0rg/set)\n\n# set\n\ngeneric set types for golang\n\n# features\n\n- both un-ordered and ordered types\n- union, diff, intersect, comparision for any two sets\n- simple API\n- zero-alloc\n- zero-dependency\n- 100% test coverage\n\n# example\n\n```go\nimport (\n    \"fmt\"\n\n    \"github.com/s0rg/set\"\n)\n\nfunc main() {\n    // create new, empty set of int's\n    s := make(set.Unordered[int]) // fastest variant as it direct functions call\n\n    // or\n\n    // second (a bit slower) form for unordered constructor, it uses indirect calls via interface\n    // s := set.NewUnordered[int]()\n\n    // ordered constructor, only this form\n    // s := set.NewOrdered[int]()\n\n    // add some values\n    s.Add(1)\n    s.Add(2)\n\n    // and some more...\n    set.Load(s, 2, 3)\n\n    // check set for value\n    if !s.Has(2) {\n        panic(\"2 not found\")\n    }\n\n    // check and add\n    if s.TryAdd(4) {\n        fmt.Println(\"value 4 wasnt in set, it there now\")\n    }\n\n    // delete item\n    s.Del(1)\n\n    fmt.Println(\"Set length:\", s.Len())\n    fmt.Println(\"Set contents:\", s.ToSlice())\n\n    // iter over items\n    for i := range s.Iter {\n        fmt.Printf(\"iter: %d\\n\", i)\n    }\n\n    s.Clear()\n\n    fmt.Println(\"Set length:\", s.Len())\n    fmt.Println(\"Set contents:\", s.ToSlice())\n}\n```\n\n# benchmarks\n```\ncpu: AMD Ryzen 5 5500U with Radeon Graphics\nBenchmarkSetUnorderedDirect/Add-12      7092192        174.1 ns/op      49 B/op          0 allocs/op\nBenchmarkSetUnorderedDirect/Has-12      17680040       97.33 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedDirect/Len-12      1000000000    0.2496 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedDirect/Pop-12      6251703         5282 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedDirect/Del-12      561568860      2.145 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedIndirect/Add-12    7479926        193.6 ns/op      46 B/op          0 allocs/op\nBenchmarkSetUnorderedIndirect/Has-12    17168162       80.38 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedIndirect/Len-12    802026860      1.496 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedIndirect/Pop-12    6782689         6487 ns/op       0 B/op          0 allocs/op\nBenchmarkSetUnorderedIndirect/Del-12    393659181      3.072 ns/op       0 B/op          0 allocs/op\nBenchmarkSetOrdered/Add-12              6576442        178.7 ns/op      67 B/op          0 allocs/op\nBenchmarkSetOrdered/Has-12              17831434       84.19 ns/op       0 B/op          0 allocs/op\nBenchmarkSetOrdered/Len-12              473897580      2.494 ns/op       0 B/op          0 allocs/op\nBenchmarkSetOrdered/Pop-12              297457706      4.054 ns/op       0 B/op          0 allocs/op\nBenchmarkSetOrdered/Del-12              144014604      8.326 ns/op       0 B/op          0 allocs/op\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0rg%2Fset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs0rg%2Fset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0rg%2Fset/lists"}