Trait roaring::MultiOps

source ·
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§

source

type Output

The type of output from operations.

Required Methods§

source

fn union(self) -> Self::Output

The union between all elements.

source

fn intersection(self) -> Self::Output

The intersection between all elements.

source

fn difference(self) -> Self::Output

The difference between all elements.

source

fn symmetric_difference(self) -> Self::Output

The symmetric difference between all elements.

Implementors§

source§

impl<'a, I> MultiOps<&'a RoaringBitmap> for I
where I: IntoIterator<Item = &'a RoaringBitmap>,

source§

impl<'a, I> MultiOps<&'a RoaringTreemap> for I
where I: IntoIterator<Item = &'a RoaringTreemap>,

source§

impl<'a, I, E: 'a> MultiOps<Result<&'a RoaringBitmap, E>> for I
where I: IntoIterator<Item = Result<&'a RoaringBitmap, E>>,

source§

impl<'a, I, E: 'a> MultiOps<Result<&'a RoaringTreemap, E>> for I
where I: IntoIterator<Item = Result<&'a RoaringTreemap, E>>,

source§

impl<I> MultiOps<RoaringBitmap> for I
where I: IntoIterator<Item = RoaringBitmap>,

source§

impl<I> MultiOps<RoaringTreemap> for I
where I: IntoIterator<Item = RoaringTreemap>,

source§

impl<I, E> MultiOps<Result<RoaringBitmap, E>> for I
where I: IntoIterator<Item = Result<RoaringBitmap, E>>,

source§

impl<I, E> MultiOps<Result<RoaringTreemap, E>> for I
where I: IntoIterator<Item = Result<RoaringTreemap, E>>,