Swiftpack.co -  RoaringBitmap/SwiftRoaring as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A better compressed bitset in Swift http://roaringbitmap.org/
.package(url: "https://github.com/RoaringBitmap/SwiftRoaring.git", from: "v1.1.0")


Swift 4 compatible Carthage compatible Ubuntu  CI

Swift wrapper for CRoaring (a C/C++ implementation at https://github.com/RoaringBitmap/CRoaring)

Roaring bitmaps are used by several important systems:

Roaring bitmaps are found to work well in many important applications:

Use Roaring for bitmap compression whenever possible. Do not use other bitmap compression methods (Wang et al., SIGMOD 2017)


Swift 4.0 or higher

Usage using Swift Package Manager

Create a directory where you will create your application:

mkdir foo
cd foo
swift package init --type executable

Then edit Package.swift so that it reads something like this:

import PackageDescription

let package = Package(
    name: "foo",
    dependencies: [
   .package(url: "https://github.com/RoaringBitmap/SwiftRoaring",  from: "0.0.1")
    targets: [
            name: "foo",
            dependencies: ["SwiftRoaring"]),

Edit main.swift (in Sources) so that it looks something like this :

import SwiftRoaring;



Here is a simplified but complete example:

import SwiftRoaring

//Create a new Roaring Bitmap
let bitmap = RoaringBitmap()

//Example: Add Range
bitmap.addRange(min: 0, max: 500)

//Example: copy
let cpy = bitmap.copy()

//Example: Operators
let and = bitmap && cpy

//Example: Iterate
for i in bitmap {

//See documentation for more functionalities!


You can build using Swift Package Manager as follows:

swift build  --configuration release
$(swift build   --configuration release  --show-bin-path)/fun

You can run tests using Swift Package Manager as follows:

swift test

Interactive use

$ swift build  -Xcc -march=native  --configuration release
$ swift -I .build/release -L .build/release -lSwiftRoaringDynamic
  1> import SwiftRoaring
  2> let bitmap = RoaringBitmap()
  3> bitmap.add(1)

Mailing list/discussion group


Compatibility with Java RoaringBitmap library

You can read bitmaps in Go, Java, C, C++ that have been serialized in Java, C, C++.


  • Daniel Lemire, Owen Kaser, Nathan Kurz, Luca Deri, Chris O'Hara, François Saint-Jacques, Gregory Ssi-Yan-Kai, Software: Practice and Experience Volume 48, Issue 4 April 2018 Pages 867-895 arXiv:1709.07821
  • Samy Chambi, Daniel Lemire, Owen Kaser, Robert Godin, Better bitmap performance with Roaring bitmaps, Software: Practice and Experience Volume 46, Issue 5, pages 709–719, May 2016 http://arxiv.org/abs/1402.6407 This paper used data from http://lemire.me/data/realroaring2014.html
  • Daniel Lemire, Gregory Ssi-Yan-Kai, Owen Kaser, Consistently faster and smaller compressed bitmaps with Roaring, Software: Practice and Experience Volume 46, Issue 11, pages 1547-1569, November 2016 http://arxiv.org/abs/1603.06549


Stars: 34
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Version 1.1.0
2 weeks ago

Added base64 demo, upgraded underlying CRoaring library.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API