pub trait MultiOps<T>: IntoIterator<Item = T> {
type Output;
// Required methods
fn union(self) -> Self::Output;
fn intersection(self) -> Self::Output;
fn difference(self) -> Self::Output;
fn symmetric_difference(self) -> Self::Output;
}Expand description
A Iterator::collect blanket implementation that provides extra methods for RoaringBitmap
and RoaringTreemap.
When merging multiple bitmap with the same operation it’s usually faster to call the method in this trait than to write your own for loop and merging the bitmaps yourself.
§Examples
use roaring::{MultiOps, RoaringBitmap};
let bitmaps = [
RoaringBitmap::from_iter(0..10),
RoaringBitmap::from_iter(10..20),
RoaringBitmap::from_iter(20..30),
];
// Stop doing this
let naive = bitmaps.clone().into_iter().reduce(|a, b| a | b).unwrap_or_default();
// And start doing this instead, it will be much faster!
let iter = bitmaps.union();
assert_eq!(naive, iter);Required Associated Types§
Required Methods§
Sourcefn intersection(self) -> Self::Output
fn intersection(self) -> Self::Output
The intersection between all elements.
Sourcefn difference(self) -> Self::Output
fn difference(self) -> Self::Output
The difference between all elements.
Sourcefn symmetric_difference(self) -> Self::Output
fn symmetric_difference(self) -> Self::Output
The symmetric difference between all elements.