All Projects → saulius → Croaring Rs

saulius / Croaring Rs

Licence: apache-2.0
Rust wrapper for CRoaring

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Croaring Rs

BitLens
🔎 Have your bits and eat them too! A C++17 bit lens container for vector types.
Stars: ✭ 20 (-77.53%)
Mutual labels:  bitset, wrapper
Tensorrtwrapper
TensorRT Net Wrapper
Stars: ✭ 81 (-8.99%)
Mutual labels:  wrapper
Roaringbitmap
Roaring Bitmap in Cython
Stars: ✭ 64 (-28.09%)
Mutual labels:  bitset
Phenomenon Px
⚡️ The fastest way to create pixel shaders.
Stars: ✭ 77 (-13.48%)
Mutual labels:  wrapper
D2sqlite3
A small wrapper around SQLite for the D programming language
Stars: ✭ 67 (-24.72%)
Mutual labels:  wrapper
Tortilla
Wrapping web APIs made easy.
Stars: ✭ 1,215 (+1265.17%)
Mutual labels:  wrapper
Roaring
Roaring bitmaps in Go (golang)
Stars: ✭ 1,118 (+1156.18%)
Mutual labels:  bitset
Spotify Web Api Kotlin
Spotify Web API wrapper for Kotlin/JVM, Kotlin/Android, Kotlin/JS, and Kotlin/Native. Includes a Spotify Web Playback SDK wrapper for Kotlin/JS, and a spotify-auth wrapper for Kotlin/Android
Stars: ✭ 86 (-3.37%)
Mutual labels:  wrapper
React Native Line
Line SDK wrapper for React Native 🚀
Stars: ✭ 80 (-10.11%)
Mutual labels:  wrapper
Csnackbar
This is a wrapper for android Snackbar. Which giving support to change Snackbar color, duration, message or even it's content view with a custom view.
Stars: ✭ 76 (-14.61%)
Mutual labels:  wrapper
Cbitset
A simple bitset library in C
Stars: ✭ 73 (-17.98%)
Mutual labels:  bitset
Hentai
Implements a wrapper class around nhentai's RESTful API.
Stars: ✭ 68 (-23.6%)
Mutual labels:  wrapper
Pswritecolor
Write-Color is a wrapper around Write-Host allowing you to create nice looking scripts, with colorized output.
Stars: ✭ 78 (-12.36%)
Mutual labels:  wrapper
Domonit
A Deadly Simple Docker Monitoring Wrapper For Docker API
Stars: ✭ 67 (-24.72%)
Mutual labels:  wrapper
Hibitset
Hierarchical bit set container
Stars: ✭ 81 (-8.99%)
Mutual labels:  bitset
Remodel
Data and class remodeling library
Stars: ✭ 63 (-29.21%)
Mutual labels:  wrapper
Swifttwitch
👾 The New Twitch API for iOS; wrapped in Swift goodness 👾
Stars: ✭ 72 (-19.1%)
Mutual labels:  wrapper
Minecraft Wrapper
A simple & intuitive Minecraft Server wrapper. Supports IRC, backups, a plugin system, and more.
Stars: ✭ 77 (-13.48%)
Mutual labels:  wrapper
Termux
Node.js module for Termux-API
Stars: ✭ 87 (-2.25%)
Mutual labels:  wrapper
Aiovk
vk.com API python wrapper for asyncio
Stars: ✭ 85 (-4.49%)
Mutual labels:  wrapper

croaring-rs https://travis-ci.org/saulius/croaring-rs

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

The original java version can be found at https://github.com/RoaringBitmap/RoaringBitmap

Bitmap usage example

use croaring::Bitmap;

let mut rb1 = Bitmap::create();
rb1.add(1);
rb1.add(2);
rb1.add(3);
rb1.add(4);
rb1.add(5);
rb1.add(100);
rb1.add(1000);
rb1.run_optimize();

let mut rb2 = Bitmap::create();
rb2.add(3);
rb2.add(4);
rb2.add(1000);
rb2.run_optimize();

let mut rb3 = Bitmap::create();

assert_eq!(rb1.cardinality(), 7);
assert!(rb1.contains(3));

rb1.and_inplace(&rb2);
rb3.add(5);
rb3.or_inplace(&rb1);

let mut rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]);

rb1.and_inplace(&rb2);
println!("{:?}", rb1);

rb3.add(5);
rb3.or_inplace(&rb1);

println!("{:?}", rb1);

rb3.add(5);
rb3.or_inplace(&rb1);

println!("{:?}", rb3.to_vec());
println!("{:?}", rb3);
println!("{:?}", rb4);

rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]);

println!("{:?}", rb4);

For 64bit Bitmap support, checkout the Treemap. Treemap is not API-compatible with Bitmap, yet most the functionality is overlapping.

Treemap usage example

use std::u64;
use croaring::Treemap;

let mut treemap = Treemap::create();
treemap.add(u64::MAX);
treemap.remove(u64::MAX);

/// Serialization compatible with croaring Treemap version at https://github.com/RoaringBitmap/CRoaring/blob/b88b002407b42fafaea23ea5009a54a24d1c1ed4/cpp/roaring64map.hh

use croaring::treemap::NativeSerializer;

let mut treemap1 = Treemap::create();

for i in 100..1000 {
  treemap1.add(i);
}

treemap1.add(std::u32::MAX as u64);
treemap1.add(std::u64::MAX);

/// Serialization compatible with JVM Treemap version at https://github.com/RoaringBitmap/RoaringBitmap/blob/34654b2d5c3e75e7f9bca1672f4c0b5800d60cf3/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java
use croaring::treemap::JvmSerializer;

let mut treemap2 = Treemap::create();

for i in 100..1000 {
  treemap2.add(i);
}

treemap2.add(std::u32::MAX as u64);
treemap2.add(std::u64::MAX);

Building

git clone --recursive https://github.com/saulius/croaring-rs/
cd croaring-rs
cargo build

As with CRoaring croaring-rs build allows the compiler to target the architecture of the build machine by using the -march=native flag. In this way the compiler is given freedom to use instructions that your CPU support. However binaries built this way can be dangerous to run on older CPU architectures (e.g. missing POPCOUNT instruction). You can specify ROARING_ARCH environment variable to control the target CPU architecture, e.g. ROARING_ARCH=ivybridge cargo build --release.

Testing

Running unit tests and doc tests:

cargo test

Running benchmark suite (currently on Rust nightly toolchain only):

cargo bench

Documentation

Current documentation is available at https://docs.rs/croaring/latest/croaring/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].