Struct roaring::RoaringBitmap
[−]
[src]
pub struct RoaringBitmap<Size: ExtInt + Halveable> where Size::HalfSize: ExtInt {
// some 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]
fn new() -> Self
Creates an empty RoaringBitmap
.
Examples
use roaring::RoaringBitmap; let mut rb: RoaringBitmap<u32> = RoaringBitmap::new();
fn insert(&mut self, value: Size) -> bool
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);
fn remove(&mut self, value: Size) -> bool
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);
fn contains(&self, value: Size) -> bool
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);
fn clear(&mut self)
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);
fn is_empty(&self) -> bool
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);
fn len(&self) -> Size
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);
fn iter<'a>(&'a self) -> Iter<'a, Size> where Size::HalfSize: 'a
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);
fn is_disjoint(&self, other: &Self) -> bool
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);
fn is_subset(&self, other: &Self) -> bool
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);
fn is_superset(&self, other: &Self) -> bool
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);
fn union<'a>(&'a self, other: &'a Self) -> UnionIter<'a, Size> where Size::HalfSize: 'a
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);
fn intersection<'a>(&'a self, other: &'a Self) -> IntersectionIter<'a, Size> where Size::HalfSize: 'a
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);
fn difference<'a>(&'a self, other: &'a Self) -> DifferenceIter<'a, Size> where Size::HalfSize: 'a
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);
fn symmetric_difference<'a>(&'a self, other: &'a Self) -> SymmetricDifferenceIter<'a, Size> where Size::HalfSize: 'a
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);
fn union_with(&mut self, other: &Self)
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);
fn intersect_with(&mut self, other: &Self)
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);
fn difference_with(&mut self, other: &Self)
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);
fn symmetric_difference_with(&mut self, other: &Self)
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: Clone + ExtInt + Halveable> Clone for RoaringBitmap<Size> where Size::HalfSize: ExtInt
[src]
fn clone(&self) -> RoaringBitmap<Size>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<Size: PartialEq + ExtInt + Halveable> PartialEq for RoaringBitmap<Size> where Size::HalfSize: ExtInt
[src]
fn eq(&self, __arg_0: &RoaringBitmap<Size>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &RoaringBitmap<Size>) -> bool
This method tests for !=
.
impl<Size: ExtInt + Halveable> IntoIterator for RoaringBitmap<Size>
[src]
type Item = Size
The type of the elements being iterated over.
type IntoIter = Vec<Size>::IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<Size: ExtInt + Halveable> FromIterator<Size> for RoaringBitmap<Size>
[src]
fn from_iter<I: IntoIterator<Item=Size>>(iterator: I) -> Self
Creates a value from an iterator. Read more
impl<'a, Size: ExtInt + Halveable + 'a> FromIterator<&'a Size> for RoaringBitmap<Size>
[src]
fn from_iter<I: IntoIterator<Item=&'a Size>>(iterator: I) -> Self
Creates a value from an iterator. Read more
impl<Size: ExtInt + Halveable> Extend<Size> for RoaringBitmap<Size>
[src]
fn extend<I: IntoIterator<Item=Size>>(&mut self, iterator: I)
Extends a collection with the contents of an iterator. Read more
impl<'a, Size: ExtInt + Halveable + 'a> Extend<&'a Size> for RoaringBitmap<Size>
[src]
fn extend<I: IntoIterator<Item=&'a Size>>(&mut self, iterator: I)
Extends a collection with the contents of an iterator. Read more
impl<Size: ExtInt + Halveable> BitOr<RoaringBitmap<Size>> for RoaringBitmap<Size>
[src]
type Output = Self
The resulting type after applying the |
operator
fn bitor(self, rhs: Self) -> Self
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the |
operator
fn bitor(self, rhs: RoaringBitmap<Size>) -> RoaringBitmap<Size>
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the |
operator
fn bitor(self, rhs: &'a RoaringBitmap<Size>) -> RoaringBitmap<Size>
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]
type Output = Self
The resulting type after applying the |
operator
fn bitor(self, rhs: &'a Self) -> Self
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]
type Output = Self
The resulting type after applying the &
operator
fn bitand(self, rhs: Self) -> Self
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]
type Output = Self
The resulting type after applying the &
operator
fn bitand(self, rhs: &'a Self) -> Self
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the &
operator
fn bitand(self, rhs: RoaringBitmap<Size>) -> RoaringBitmap<Size>
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the &
operator
fn bitand(self, rhs: &'a RoaringBitmap<Size>) -> RoaringBitmap<Size>
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]
type Output = Self
The resulting type after applying the -
operator
fn sub(self, rhs: Self) -> Self
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]
type Output = Self
The resulting type after applying the -
operator
fn sub(self, rhs: &'a Self) -> Self
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the -
operator
fn sub(self, rhs: &'a RoaringBitmap<Size>) -> RoaringBitmap<Size>
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]
type Output = Self
The resulting type after applying the ^
operator
fn bitxor(self, rhs: Self) -> Self
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: &'a Self) -> Self
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: RoaringBitmap<Size>) -> RoaringBitmap<Size>
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]
type Output = RoaringBitmap<Size>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: &'a RoaringBitmap<Size>) -> RoaringBitmap<Size>
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);