{"id":26720945,"url":"https://github.com/cospectrum/linear-map","last_synced_at":"2025-03-27T19:35:07.669Z","repository":{"id":209112423,"uuid":"723266540","full_name":"cospectrum/linear-map","owner":"cospectrum","description":" A map implemented by searching linearly in a slice of (key, value). Intended for use with a small number of elements.","archived":false,"fork":false,"pushed_at":"2024-03-02T21:09:24.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-02T22:21:40.740Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cospectrum.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}},"created_at":"2023-11-25T05:43:09.000Z","updated_at":"2024-03-02T22:21:41.324Z","dependencies_parsed_at":"2023-11-25T06:28:37.510Z","dependency_job_id":"ff50b117-25af-454f-9d46-a64813070431","html_url":"https://github.com/cospectrum/linear-map","commit_stats":null,"previous_names":["cospectrum/linear-map"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Flinear-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Flinear-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Flinear-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Flinear-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cospectrum","download_url":"https://codeload.github.com/cospectrum/linear-map/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245911580,"owners_count":20692615,"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":"2025-03-27T19:35:06.290Z","updated_at":"2025-03-27T19:35:07.618Z","avatar_url":"https://github.com/cospectrum.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LinearMap\n[![github]](https://github.com/cospectrum/linear-map)\n[![goref]](https://pkg.go.dev/github.com/cospectrum/linear-map)\n\n[github]: https://img.shields.io/badge/github-cospectrum/linear--map-8da0cb?logo=github\n[goref]: https://pkg.go.dev/badge/github.com/cospectrum/linear-map\n\nA map implemented by searching linearly in a slice of (key, value).\n\nIntended for use with a small number of elements.\n\n## Install\n\n```sh\ngo get github.com/cospectrum/linear-map\n```\nRequires Go version 1.18 or greater.\n\n## Usage\n\n```go\npackage main\n\nimport \"github.com/cospectrum/linear-map/linearmap\"\n\nfunc main() {\n\tm := linearmap.New[int, string]() // empty\n\tm.Put(1, \"x\")                   // 1-\u003ex\n\tm.Put(2, \"b\")                   // 1-\u003ex, 2-\u003eb\n\tm.Put(1, \"a\")                   // 1-\u003ea, 2-\u003eb\n\t_, _ = m.Get(2)                 // b, true\n\t_, _ = m.Get(3)                 // \"\", false\n\t_ = m.Values()                  // []string{\"a\", \"b\"}\n\t_ = m.Keys()                    // []int{1, 2}\n\tm.Remove(1)                     // 2-\u003eb\n\tm.Clear()                       // empty\n\tm.Empty()                       // true\n\tm.Size()                        // 0\n}\n```\n\n## Benchmarks\n\nBenchmarks are performed on arm64 with Key=int, Value=struct{}.\n\nThe lower is better\n\nLength: 10\n| Method | LinearMap | map |\n| ---- | ------------ | ------ |\n| Get | 27 ns/op | 49 ns/op |\n| Put | 30 ns/op | 70 ns/op |\n| Remove | 7 ns/op | 16 ns/op |\n\nLength: 20\n| Method | LinearMap | map |\n| ---- | ------------ | ------ |\n| Get | 85 ns/op | 97 ns/op |\n| Put | 92 ns/op | 140 ns/op |\n| Remove | 13 ns/op | 29 ns/op |\n\nLength: 30\n| Method | LinearMap | map |\n| ---- | ------------ | ------ |\n| Get | 174 ns/op | 147 ns/op |\n| Put | 184 ns/op | 198 ns/op |\n| Remove | 20 ns/op | 67 ns/op |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcospectrum%2Flinear-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcospectrum%2Flinear-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcospectrum%2Flinear-map/lists"}