Struct roaring::bitmap::RoaringBitmap [] [src]

pub struct RoaringBitmap { /* fields omitted */ }

A compressed bitmap using the Roaring bitmap compression scheme.

Examples

use roaring::RoaringBitmap;

let mut rb = 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 RoaringBitmap
[src]

Creates an empty RoaringBitmap.

Examples

use roaring::RoaringBitmap;
let mut rb = 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::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::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::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::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::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::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);

Returns the minimum value in the set (if the set is non-empty).

Examples

use roaring::RoaringBitmap;

let mut rb = RoaringBitmap::new();
assert_eq!(rb.min(), None);

rb.insert(3);
rb.insert(4);
assert_eq!(rb.min(), Some(3));

Returns the maximum value in the set (if the set is non-empty).

Examples

use roaring::RoaringBitmap;

let mut rb = RoaringBitmap::new();
assert_eq!(rb.max(), None);

rb.insert(3);
rb.insert(4);
assert_eq!(rb.max(), Some(4));

impl RoaringBitmap
[src]

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

Examples

use roaring::RoaringBitmap;
use std::iter::FromIterator;

let bitmap = RoaringBitmap::from_iter(1..3);
let mut iter = bitmap.iter();

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

impl RoaringBitmap
[src]

Unions in-place with the specified other bitmap.

Examples

use roaring::RoaringBitmap;

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

rb1.union_with(&rb2);

assert_eq!(rb1, rb3);

Can also be done via the BitOr operator.

use roaring::RoaringBitmap;

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

let rb1 = rb1 | rb2;

assert_eq!(rb1, rb3);

Intersects in-place with the specified other bitmap.

Examples

use roaring::RoaringBitmap;

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

rb1.intersect_with(&rb2);

assert_eq!(rb1, rb3);

Can also be done via the BitAnd operator.

use roaring::RoaringBitmap;

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

let rb1 = rb1 & 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 = (1..4).collect();
let rb2: RoaringBitmap = (3..5).collect();
let rb3: RoaringBitmap = (1..3).collect();

rb1.difference_with(&rb2);

assert_eq!(rb1, rb3);

Can also be done via the Sub operator.

use roaring::RoaringBitmap;

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

let rb1 = rb1 - 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 = (1..4).collect();
let rb2: RoaringBitmap = (3..6).collect();
let rb3: RoaringBitmap = (1..3).chain(4..6).collect();

rb1.symmetric_difference_with(&rb2);

assert_eq!(rb1, rb3);

Can also be done via the BitXor operator.

use roaring::RoaringBitmap;

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

let rb1 = rb1 ^ rb2;

assert_eq!(rb1, rb3);

impl RoaringBitmap
[src]

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::new();
let mut rb2 = 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::new();
let mut rb2 = 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 superset of other.

Examples

use roaring::RoaringBitmap;

let mut rb1 = RoaringBitmap::new();
let mut rb2 = 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);

impl RoaringBitmap
[src]

Return the size in bytes of the serialized output. This is compatible with the official C/C++, Java and Go implementations.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap = (1..4).collect();
let mut bytes = Vec::with_capacity(rb1.serialized_size());
rb1.serialize_into(&mut bytes).unwrap();
let rb2 = RoaringBitmap::deserialize_from(&mut &bytes[..]).unwrap();

assert_eq!(rb1, rb2);

Serialize this bitmap into the standard Roaring on-disk format. This is compatible with the official C/C++, Java and Go implementations.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap = (1..4).collect();
let mut bytes = vec![];
rb1.serialize_into(&mut bytes).unwrap();
let rb2 = RoaringBitmap::deserialize_from(&mut &bytes[..]).unwrap();

assert_eq!(rb1, rb2);

Deserialize a bitmap into memory from the standard Roaring on-disk format. This is compatible with the official C/C++, Java and Go implementations.

Examples

use roaring::RoaringBitmap;

let rb1: RoaringBitmap = (1..4).collect();
let mut bytes = vec![];
rb1.serialize_into(&mut bytes).unwrap();
let rb2 = RoaringBitmap::deserialize_from(&mut &bytes[..]).unwrap();

assert_eq!(rb1, rb2);

Trait Implementations

impl Debug for RoaringBitmap
[src]

Formats the value using the given formatter.

impl Default for RoaringBitmap
[src]

Returns the "default value" for a type. Read more

impl<'a> IntoIterator for &'a RoaringBitmap
[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 IntoIterator for RoaringBitmap
[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 FromIterator<u32> for RoaringBitmap
[src]

Creates a value from an iterator. Read more

impl Extend<u32> for RoaringBitmap
[src]

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

impl BitOr<RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the | operator

The method for the | operator

impl<'a> BitOr<&'a RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the | operator

The method for the | operator

impl<'a> BitOr<RoaringBitmap> for &'a RoaringBitmap
[src]

The resulting type after applying the | operator

The method for the | operator

impl<'a, 'b> BitOr<&'a RoaringBitmap> for &'b RoaringBitmap
[src]

The resulting type after applying the | operator

The method for the | operator

impl BitOrAssign<RoaringBitmap> for RoaringBitmap
[src]

The method for the |= operator

impl<'a> BitOrAssign<&'a RoaringBitmap> for RoaringBitmap
[src]

The method for the |= operator

impl BitAnd<RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a> BitAnd<&'a RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a> BitAnd<RoaringBitmap> for &'a RoaringBitmap
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a, 'b> BitAnd<&'a RoaringBitmap> for &'b RoaringBitmap
[src]

The resulting type after applying the & operator

The method for the & operator

impl BitAndAssign<RoaringBitmap> for RoaringBitmap
[src]

The method for the &= operator

impl<'a> BitAndAssign<&'a RoaringBitmap> for RoaringBitmap
[src]

The method for the &= operator

impl Sub<RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a> Sub<&'a RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a> Sub<RoaringBitmap> for &'a RoaringBitmap
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, 'b> Sub<&'a RoaringBitmap> for &'b RoaringBitmap
[src]

The resulting type after applying the - operator

The method for the - operator

impl SubAssign<RoaringBitmap> for RoaringBitmap
[src]

The method for the -= operator

impl<'a> SubAssign<&'a RoaringBitmap> for RoaringBitmap
[src]

The method for the -= operator

impl BitXor<RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a> BitXor<&'a RoaringBitmap> for RoaringBitmap
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a> BitXor<RoaringBitmap> for &'a RoaringBitmap
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a, 'b> BitXor<&'a RoaringBitmap> for &'b RoaringBitmap
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl BitXorAssign<RoaringBitmap> for RoaringBitmap
[src]

The method for the ^= operator

impl<'a> BitXorAssign<&'a RoaringBitmap> for RoaringBitmap
[src]

The method for the ^= operator

impl PartialEq for RoaringBitmap
[src]

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

This method tests for !=.

impl Clone for RoaringBitmap
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more