{"id":13562418,"url":"https://github.com/Cantido/int_set","last_synced_at":"2025-04-03T18:33:40.797Z","repository":{"id":28989485,"uuid":"119931563","full_name":"Cantido/int_set","owner":"Cantido","description":"A time- and memory-efficient data structure for positive integers.","archived":false,"fork":false,"pushed_at":"2025-03-11T22:36:12.000Z","size":371,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T10:12:09.328Z","etag":null,"topics":["bitfield","bitfields","bittorrent","collection","elixir","enumerable","hacktoberfest","set"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/int_set","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cantido.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"code_of_conduct.md","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":"2018-02-02T04:24:29.000Z","updated_at":"2025-03-11T22:36:08.000Z","dependencies_parsed_at":"2023-10-05T03:10:36.782Z","dependency_job_id":"e7ced385-9947-4a8b-a6d9-bca59be49527","html_url":"https://github.com/Cantido/int_set","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cantido%2Fint_set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cantido%2Fint_set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cantido%2Fint_set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cantido%2Fint_set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cantido","download_url":"https://codeload.github.com/Cantido/int_set/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247057071,"owners_count":20876508,"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":["bitfield","bitfields","bittorrent","collection","elixir","enumerable","hacktoberfest","set"],"created_at":"2024-08-01T13:01:08.405Z","updated_at":"2025-04-03T18:33:35.789Z","avatar_url":"https://github.com/Cantido.png","language":"Elixir","readme":"\u003c!--\nSPDX-FileCopyrightText: 2024 Rosa Richter\n\nSPDX-License-Identifier: CC-BY-SA-4.0\n--\u003e\n\n# IntSet\n\n[![Hex.pm](https://img.shields.io/hexpm/v/int_set)](https://hex.pm/packages/int_set)\n[![CI](https://github.com/Cantido/int_set/actions/workflows/elixir.yml/badge.svg)](https://github.com/Cantido/int_set/actions/workflows/elixir.yml)\n\nA time- and memory-efficient data structure for positive integers.\n\nFaster than Elixir's MapSet at set operations (union, intersection, difference, equality),\nand slower at everything else.\nAlso can be serlialized wicked small.\n\n## Install\n\nThis package can be installed by adding `int_set` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:int_set, \"~\u003e 1.5\"}\n  ]\nend\n```\n\nThe docs can be found at [https://hexdocs.pm/int_set](https://hexdocs.pm/int_set).\n\n## Usage\n\nUsage is pretty much the same as with `MapSet`,\nbut you're only allowed to put positive integers (including zero) into the set.\n\nA set can be constructed using `IntSet.new/0`:\n\n```elixir\niex\u003e IntSet.new()\nIntSet.new([])\n```\n\nAn `IntSet` obeys the same set semantics as `MapSet`, and provides\nconstant-time operations for insertion, deletion, and membership checking.\nUse `Enum.member?/2` to check for membership.\n\n```elixir\niex\u003e IntSet.new(3) |\u003e Enum.member?(3)\ntrue\n```\n\nSets also implement `Collectable`, so it can collect values in any context\nthat a list can:\n\n```elixir\niex\u003e Enum.into([1, 2, 3], IntSet.new())\nIntSet.new([1, 2, 3])\n```\n\nThe `inspect/1` implementation for `IntSet` sorts the members, which makes\nit way easier to write doctests:\n\n```elixir\niex\u003e IntSet.new([3, 1, 2])\nIntSet.new([1, 2, 3])\n```\n\nWorking with applications that use bitstrings becomes way easier,\nbecause `IntSet.new/1` accepts a bitstring,\nand `IntSet.bitstring/2` can return one.\n\n```elixir\niex\u003e IntSet.new(5) |\u003e IntSet.bitstring()\n\u003c\u003c4\u003e\u003e\n\niex\u003e IntSet.new(\u003c\u003c0::1, 0::1, 0::1, 0::1, 0::1, 1::1\u003e\u003e)\nIntSet.new([5])\n```\n\nThis also means that an `IntSet` can be really efficiently serialized with the use of `IntSet.bitstring/2`, and `IntSet.new/1`.\n\n```elixir\niex\u003e IntSet.new([4, 8, 15, 16, 23, 42]) |\u003e IntSet.bitstring() |\u003e Base.encode16()\n\"088181000020\"\niex\u003e Base.decode16!(\"088181000020\") |\u003e IntSet.new()\nIntSet.new([4, 8, 15, 16, 23, 42])\n```\n\n## Performance\n\nCheck out the iterations-per-second for some operations of `MapSet` compared to `IntSet`.\n\n| Op           | MapSet | IntSet  | Comparison    |\n|--------------|--------|---------|---------------|\n| new          | 4.8K   | 2.46K   | 1.95x slower  |\n| member?      | 6.78M  | 2.93M   | 2.31x slower  |\n| put          | 4.19M  | 1.15M   | 3.66x slower  |\n| union        | 156.4K | 944.31K | 6.04x faster  |\n| difference   | 48.09  | 891.27K | 18.53x faster |\n| intersection | 14.03K | 905.70K | 64.54x faster |\n| equal?       | 0.26M  | 2.41M   | 9.25x faster  |\n\nMemory usage is also better for union, difference, intersection, and equality.\nSee the [`benchmarks/results`] directory for all the benchmarks.\nYou can run the benchmarks for yourself with `mix run benchmarks/benchmark.exs`.\n\n## Maintainer\n\nThis project was developed by [Rosa Richter](https://github.com/Cantido).\nYou can get in touch with her on [Keybase.io](https://keybase.io/cantido).\n\n## Contributing\n\nQuestions and pull requests are more than welcome.\nI follow Elixir's tenet of bad documentation being a bug,\nso if anything is unclear, please [file an issue](https://github.com/Cantido/int_set/issues/new)!\nIdeally, my answer to your question will be in an update to the docs.\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for all the details you could ever want about helping me with this project.\n\nNote that this project is released with a Contributor [Code of Conduct].\nBy participating in this project you agree to abide by its terms.\n\n## License\n\nCopyright 2024 Rosa Richter\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program.  If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n","funding_links":[],"categories":["Code Analysis"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCantido%2Fint_set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCantido%2Fint_set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCantido%2Fint_set/lists"}