{"id":16572745,"url":"https://github.com/lemire/swiftbitset","last_synced_at":"2025-03-21T12:31:14.046Z","repository":{"id":46695184,"uuid":"68729329","full_name":"lemire/SwiftBitset","owner":"lemire","description":"A fast Bitset class in Swift ","archived":false,"fork":false,"pushed_at":"2019-07-09T00:31:33.000Z","size":90,"stargazers_count":39,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T21:28:27.785Z","etag":null,"topics":["bitset","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/lemire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-20T16:05:17.000Z","updated_at":"2024-01-16T15:28:51.000Z","dependencies_parsed_at":"2022-09-13T15:32:51.302Z","dependency_job_id":null,"html_url":"https://github.com/lemire/SwiftBitset","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSwiftBitset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSwiftBitset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSwiftBitset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSwiftBitset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemire","download_url":"https://codeload.github.com/lemire/SwiftBitset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221815131,"owners_count":16885127,"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":["bitset","swift"],"created_at":"2024-10-11T21:28:29.112Z","updated_at":"2024-10-28T10:07:16.851Z","avatar_url":"https://github.com/lemire.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftBitset\n\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift4-compatible-green.svg?style=flat\" alt=\"Swift 4 compatible\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/apple/swift-package-manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg\"/\u003e\u003c/a\u003e\n[![Build Status](https://travis-ci.org/lemire/SwiftBitset.svg?branch=master)](https://travis-ci.org/lemire/SwiftBitset)\n\nA bitset class in Swift for fast and concise set operations over integers. Works under both Linux and MacOS.\nIt is engineered to be really fast, on par with portable C/C++ implementations.\n\nIt can be orders of magnitude faster than an IndexSet:\n\n```\n$ git clone https://github.com/lemire/SwiftBitsetBenchmark.git\n$ cd SwiftBitsetBenchmark\n$ swift build  -Xcc -march=native  --configuration release\n\n$ $(swift build   --configuration release --show-bin-path)/SwiftBitsetBenchmark\ntestAddPerformance  10.693318  ms\ntestIndexSetAddPerformance  231.737616  ms\n\ntestCountPerformance  0.617098  ms\ntestIndexSetCountPerformance  0.007483  ms\n\ntestIteratorPerformance  5.503873  ms\ntestIndexSetIteratorPerformance  234.289692  ms\n\ntestIntersectionPerformance  3.157883  ms\ntestIndexSetIntersectionPerformance  2774.959423  ms\n```\n\nSee https://github.com/lemire/SwiftBitsetBenchmark\n\n## Complete example for library users\n\nCreate a directory where you will create your application:\n\n```bash\nmkdir fun\ncd fun\nswift package init --type executable\n```\n\nThen edit ``Package.swift`` so that it reads something like this:\n\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"fun\",\n    dependencies: [\n   .package(url: \"https://github.com/lemire/SwiftBitset.git\",  from: \"0.3.2\")\n    ],\n    targets: [\n        .target(\n            name: \"fun\",\n            dependencies: [\"Bitset\"]),\n    ]\n)\n```\n\nEdit ``main.swift`` (in Sources) so that it looks something like this :\n\n```swift\nimport Bitset;\n\nlet b1 = Bitset (arrayLiteral: 1,4,10,1000,10000);\nfor i in b1 {\n  print(i)\n}\n```\n\nYou can run your example as follows:\n\n```bash    \nswift build  -Xcc -march=native  --configuration release\n$(swift build   --configuration release  --show-bin-path)/fun\n```\n\n\n## Code example\n\n```swift\nimport Bitset;\n\nlet b1 = Bitset ();\nb1.add(10000) // can add one\nb1.addMany(1,4,10,1000,10000); // can add many\nlet b2 = Bitset ();\nb2.addMany(1,3,10,1000);\nlet bexpected = Bitset (1,3,4,10,1000,10000); // can init with list\nb2.union(b1)\nprint(b2.count() == 6) // print true\nprint(b2 == bexpected) // print true\nbexpected.intersection(b1)\nprint(b1 == bexpected) // print true\nfor i in b1 {\n  print(i)\n}\n// will print 1 4 10 1000 10000\nb1.remove(4) // can remove values\nlet d1 = b1 \u0026 b2;// intersection\nlet d2 = b1 | b2;// union\nlet d3 = b1 - b2;// difference\nlet d4 = b1 ^ b2;// symmetric difference\nb1 \u0026= b2;// inplace intersection\nb1 |= b2;// inplace union\nb1 -= b2;// inplace difference\nb1 ^= b2;// inplace symmetric difference\n```\n\n## Usage for contributors\n\n```bash\nswift build -Xcc -march=native --configuration release\nswift test # optional\n```\n\nTo dissamble a function...\n\n```bash\nswift build -Xcc -march=native --configuration release\nlldb ./.build/release/Bitset.build/Bitset.swift.o\ndisassemble -n intersectionCount\n```\n\nTo benchmark from the command line:\n```\nswift test -Xswiftc -Ounchecked -s BitsetTests.BitsetTests/testForEachPerformance\n```\n\nFor interactive use:\n```bash\n$ swift build -Xcc -march=native --configuration release\n$ swift -I .build/release -L .build/release -lBitsetDynamic\n  1\u003e import Bitset\n  2\u003e let b1 = Bitset ()\n  3\u003e print(b1)\n```\n\n## For Xcode users (Mac Only)\n\n```bash\n$ swift package generate-xcodeproj\ngenerated: ./Bitset.xcodeproj\n$ open ./SwiftBitset.xcodeproj\n```\n\n## Licensing\n\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fswiftbitset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemire%2Fswiftbitset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fswiftbitset/lists"}