Struct roaring::RoaringBitmap [] [src]

pub struct RoaringBitmap<Size: ExtInt + Halveable> where Size::HalfSize: ExtInt { /* fields omitted */ }

A compressed bitmap using the Roaring bitmap compression scheme.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();

// insert all primes less than 10
rb.insert(2);
rb.insert(3);
rb.insert(5);
rb.insert(7);
println!("total bits set to true: {}", rb.len());

Methods

impl<Size: ExtInt + Halveable> RoaringBitmap<Size>
[src]

Creates an empty RoaringBitmap.

Examples

use roaring::RoaringBitmap;
let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();

Adds a value to the set. Returns true if the value was not already present in the set.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
assert_eq!(rb.insert(3), true);
assert_eq!(rb.insert(3), false);
assert_eq!(rb.contains(3), true);

Removes a value from the set. Returns true if the value was present in the set.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
rb.insert(3);
assert_eq!(rb.remove(3), true);
assert_eq!(rb.remove(3), false);
assert_eq!(rb.contains(3), false);

Returns true if this set contains the specified integer.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
rb.insert(1);
assert_eq!(rb.contains(0), false);
assert_eq!(rb.contains(1), true);
assert_eq!(rb.contains(100), false);

Clears all integers in this set.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
rb.insert(1);
assert_eq!(rb.contains(1), true);
rb.clear();
assert_eq!(rb.contains(1), false);

Returns true if there are no integers in this set.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
assert_eq!(rb.is_empty(), true);

rb.insert(3);
assert_eq!(rb.is_empty(), false);

Returns the number of distinct integers added to the set.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
assert_eq!(rb.len(), 0);

rb.insert(3);
assert_eq!(rb.len(), 1);

rb.insert(3);
rb.insert(4);
assert_eq!(rb.len(), 2);

Iterator over each value stored in the RoaringBitmap, guarantees values are ordered by value.

Examples

use roaring::RoaringBitmap;

let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();

rb.insert(1);
rb.insert(6);
rb.insert(4);

let mut iter = rb.iter();

assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), Some(6));
assert_eq!(iter.next(), None);

Returns true if the set has no elements in common with other. This is equivalent to checking for an empty intersection.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);

assert_eq!(rb1.is_disjoint(&rb2), true);

rb2.insert(1);

assert_eq!(rb1.is_disjoint(&rb2), false);

Returns true if this set is a subset of other.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);

assert_eq!(rb1.is_subset(&rb2), false);

rb2.insert(1);

assert_eq!(rb1.is_subset(&rb2), true);

rb1.insert(2);

assert_eq!(rb1.is_subset(&rb2), false);

Returns true if this set is a subset of other.

Returns true if this set is a superset of other.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);

assert_eq!(rb2.is_superset(&rb1), false);

rb2.insert(1);

assert_eq!(rb2.is_superset(&rb1), true);

rb1.insert(2);

assert_eq!(rb2.is_superset(&rb1), false);

Returns an iterator over the union of this bitmap with the other bitmap.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);
rb1.insert(2);

rb2.insert(1);
rb2.insert(3);

let mut iter = rb1.union(&rb2);

assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), None);

Returns an iterator over the intersection of this bitmap with the other bitmap.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);
rb1.insert(2);
rb1.insert(4);

rb2.insert(1);
rb2.insert(3);
rb2.insert(4);

let mut iter = rb1.intersection(&rb2);

assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), None);

Returns an iterator over the set of values in this that are not in other.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);
rb1.insert(2);
rb1.insert(4);

rb2.insert(1);
rb2.insert(3);
rb2.insert(4);

let mut iter1 = rb1.difference(&rb2);

assert_eq!(iter1.next(), Some(2));
assert_eq!(iter1.next(), None);

let mut iter2 = rb2.difference(&rb1);

assert_eq!(iter2.next(), Some(3));
assert_eq!(iter2.next(), None);

Returns an iterator over the set of values in this that are not in other + in other that are not in this.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = RoaringBitmap::new();
let mut rb2: RoaringBitmap<u32> = RoaringBitmap::new();

rb1.insert(1);
rb1.insert(2);
rb1.insert(4);

rb2.insert(1);
rb2.insert(3);
rb2.insert(4);

let mut iter = rb1.symmetric_difference(&rb2);

assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), None);

Unions in-place with the specified other bitmap.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..5u32).collect();

rb1.union_with(&rb2);

assert_eq!(rb1, rb3);

Intersects in-place with the specified other bitmap.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..5u32).collect();
let rb3: RoaringBitmap<u32> = (3..4u32).collect();

rb1.intersect_with(&rb2);

assert_eq!(rb1, rb3);

Removes all values in the specified other bitmap from self, in-place.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..3u32).collect();

rb1.difference_with(&rb2);

assert_eq!(rb1, rb3);

Replaces this bitmap with one that is equivalent to self XOR other.

Examples

use roaring::RoaringBitmap;

let mut rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..6u32).collect();
let rb3: RoaringBitmap<u32> = ((1..3u32).chain(4..6u32)).collect();

rb1.symmetric_difference_with(&rb2);

assert_eq!(rb1, rb3);

Trait Implementations

impl<Size: PartialEq + ExtInt + Halveable> PartialEq for RoaringBitmap<Size> where Size::HalfSize: ExtInt
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<Size: Clone + ExtInt + Halveable> Clone for RoaringBitmap<Size> where Size::HalfSize: ExtInt
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<Size: ExtInt + Halveable> IntoIterator for RoaringBitmap<Size>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<Size: ExtInt + Halveable> FromIterator<Size> for RoaringBitmap<Size>
[src]

Creates a value from an iterator. Read more

impl<'a, Size: ExtInt + Halveable + 'a> FromIterator<&'a Size> for RoaringBitmap<Size>
[src]

Creates a value from an iterator. Read more

impl<Size: ExtInt + Halveable> Extend<Size> for RoaringBitmap<Size>
[src]

Extends a collection with the contents of an iterator. Read more

impl<'a, Size: ExtInt + Halveable + 'a> Extend<&'a Size> for RoaringBitmap<Size>
[src]

Extends a collection with the contents of an iterator. Read more

impl<Size: ExtInt + Halveable> BitOr<RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the | operator

Unions the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..5u32).collect();

let rb4 = rb1 | rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> BitOr<RoaringBitmap<Size>> for &'a RoaringBitmap<Size>
[src]

The resulting type after applying the | operator

Unionsrhs and self, writes result in place to rhs.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..5u32).collect();

let rb4 = &rb1 | rb2;

assert_eq!(rb3, rb4);

impl<'a, 'b, Size: ExtInt + Halveable> BitOr<&'a RoaringBitmap<Size>> for &'b RoaringBitmap<Size>
[src]

The resulting type after applying the | operator

Unionsrhs and self, allocates new bitmap for result.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..5u32).collect();

let rb4 = rb1 | &rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> BitOr<&'a RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the | operator

Unions the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..5u32).collect();

let rb4 = rb1 | &rb2;

assert_eq!(rb3, rb4);

impl<Size: ExtInt + Halveable> BitAnd<RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the & operator

Intersects the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (2..4u32).collect();

let rb4 = rb1 & rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> BitAnd<&'a RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the & operator

Intersects the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (2..4u32).collect();

let rb4 = rb1 & &rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> BitAnd<RoaringBitmap<Size>> for &'a RoaringBitmap<Size>
[src]

The resulting type after applying the & operator

Intersects self into the rhs RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (2..4u32).collect();

let rb4 = &rb1 & rb2;

assert_eq!(rb3, rb4);

impl<'a, 'b, Size: ExtInt + Halveable> BitAnd<&'a RoaringBitmap<Size>> for &'b RoaringBitmap<Size>
[src]

The resulting type after applying the & operator

Intersects self and rhs into a new RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (2..5u32).collect();
let rb3: RoaringBitmap<u32> = (2..4u32).collect();

let rb4 = &rb1 & &rb2;

assert_eq!(rb3, rb4);

impl<Size: ExtInt + Halveable> Sub<RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the - operator

Subtracts the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..3u32).collect();

let rb4 = rb1 - rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> Sub<&'a RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the - operator

Subtracts the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..3u32).collect();

let rb4 = rb1 - &rb2;

assert_eq!(rb3, rb4);

impl<'a, 'b, Size: ExtInt + Halveable> Sub<&'a RoaringBitmap<Size>> for &'b RoaringBitmap<Size>
[src]

The resulting type after applying the - operator

Subtracts rhs from self and allocates a new RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..5u32).collect();
let rb3: RoaringBitmap<u32> = (1..3u32).collect();

let rb4 = &rb1 - &rb2;

assert_eq!(rb3, rb4);

impl<Size: ExtInt + Halveable> BitXor<RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the ^ operator

Subtracts the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..6u32).collect();
let rb3: RoaringBitmap<u32> = ((1..3u32).chain(4..6u32)).collect();

let rb4 = rb1 ^ rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> BitXor<&'a RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]

The resulting type after applying the ^ operator

Exclusive ors the rhs into this RoaringBitmap.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..6u32).collect();
let rb3: RoaringBitmap<u32> = ((1..3u32).chain(4..6u32)).collect();

let rb4 = rb1 ^ &rb2;

assert_eq!(rb3, rb4);

impl<'a, Size: ExtInt + Halveable> BitXor<RoaringBitmap<Size>> for &'a RoaringBitmap<Size>
[src]

The resulting type after applying the ^ operator

Exclusive ors rhs and self, writes result in place to rhs.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..6u32).collect();
let rb3: RoaringBitmap<u32> = ((1..3u32).chain(4..6u32)).collect();

let rb4 = &rb1 ^ rb2;

assert_eq!(rb3, rb4);

impl<'a, 'b, Size: ExtInt + Halveable> BitXor<&'a RoaringBitmap<Size>> for &'b RoaringBitmap<Size>
[src]

The resulting type after applying the ^ operator

Exclusive ors rhs and self, allocates a new bitmap for the result.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap<u32> = (1..4u32).collect();
let rb2: RoaringBitmap<u32> = (3..6u32).collect();
let rb3: RoaringBitmap<u32> = ((1..3u32).chain(4..6u32)).collect();

let rb4 = &rb1 ^ &rb2;

assert_eq!(rb3, rb4);

impl<Size: ExtInt + Halveable + Debug> Debug for RoaringBitmap<Size>
[src]

Formats the value using the given formatter.