Struct croaring::bitmap::BitmapView
source · pub struct BitmapView<'a> { /* private fields */ }Expand description
A frozen view of a bitmap, backed by a byte slice
All read-only methods for Bitmap are also usable on a BitmapView
Implementations§
source§impl<'a> BitmapView<'a>
impl<'a> BitmapView<'a>
sourcepub unsafe fn deserialize<S: ViewDeserializer>(data: &'a [u8]) -> Self
pub unsafe fn deserialize<S: ViewDeserializer>(data: &'a [u8]) -> Self
Create a bitmap view of a slice of data without copying
§Examples
use croaring::{Bitmap, BitmapView, Portable};
let orig_bitmap = Bitmap::of(&[1, 2, 3, 4]);
let mut buf = [0; 1024];
let data: &[u8] = orig_bitmap.try_serialize_into::<Portable>(&mut buf).unwrap();
let view = unsafe { BitmapView::deserialize::<Portable>(data) };
assert!(view.contains_range(1..=4));
assert_eq!(orig_bitmap, view);§Safety
The data must be the result of serializing a bitmap with the same serialization format
sourcepub fn to_bitmap(&self) -> Bitmap
pub fn to_bitmap(&self) -> Bitmap
Create an owned, mutable bitmap from this view
§Examples
use croaring::{Bitmap, BitmapView, Portable};
let orig_bitmap = Bitmap::of(&[1, 2, 3, 4]);
let mut buf = [0; 1024];
let data: &[u8] = orig_bitmap.try_serialize_into::<Portable>(&mut buf).unwrap();
let view: BitmapView = unsafe { BitmapView::deserialize::<Portable>(data) };
let mut mutable_bitmap: Bitmap = view.to_bitmap();
assert_eq!(view, mutable_bitmap);
mutable_bitmap.add(10);
assert!(!view.contains(10));
assert!(mutable_bitmap.contains(10));Methods from Deref<Target = Bitmap>§
sourcepub fn contains_range<R: RangeBounds<u32>>(&self, range: R) -> bool
pub fn contains_range<R: RangeBounds<u32>>(&self, range: R) -> bool
Check whether a range of values of range are present
§Examples
use croaring::Bitmap;
let bitmap = Bitmap::of(&[1, 2]);
assert!(bitmap.contains_range((1..3)));
let mut bitmap = bitmap.clone();
bitmap.add(u32::MAX - 1);
bitmap.add(u32::MAX);
assert!(bitmap.contains_range((u32::MAX - 1)..=u32::MAX))sourcepub fn contains(&self, element: u32) -> bool
pub fn contains(&self, element: u32) -> bool
Contains returns true if the integer element is contained in the bitmap
§Examples
use croaring::Bitmap;
let bitmap = Bitmap::of(&[1]);
assert!(bitmap.contains(1));
assert!(!bitmap.contains(2));sourcepub fn add_offset(&self, offset: i64) -> Self
pub fn add_offset(&self, offset: i64) -> Self
Compute a new bitmap, which contains all values from this bitmap, but shifted by offset
Any values which would be < 0, or > u32::MAX are dropped.
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[0, 1, 1000, u32::MAX]);
let shifted_down = bitmap1.add_offset(-1);
assert_eq!(shifted_down.iter().collect::<Vec<_>>(), [0, 999, u32::MAX - 1]);
let shifted_up = bitmap1.add_offset(1);
assert_eq!(shifted_up.iter().collect::<Vec<_>>(), [1, 2, 1001]);
let big_shifted = bitmap1.add_offset(i64::from(u32::MAX) + 1);
assert_eq!(big_shifted.iter().collect::<Vec<_>>(), []);sourcepub fn range_cardinality<R: RangeBounds<u32>>(&self, range: R) -> u64
pub fn range_cardinality<R: RangeBounds<u32>>(&self, range: R) -> u64
Returns number of elements in range
§Examples
use croaring::Bitmap;
let bitmap = Bitmap::of(&[1, 3, 4]);
assert_eq!(bitmap.range_cardinality((..1)), 0);
assert_eq!(bitmap.range_cardinality((..2)), 1);
assert_eq!(bitmap.range_cardinality((2..5)), 2);
assert_eq!(bitmap.range_cardinality((..5)), 3);
assert_eq!(bitmap.range_cardinality((1..=4)), 3);sourcepub fn cardinality(&self) -> u64
pub fn cardinality(&self) -> u64
Returns the number of integers contained in the bitmap
§Examples
use croaring::Bitmap;
let bitmap = Bitmap::of(&[1]);
assert_eq!(bitmap.cardinality(), 1);
let mut bitmap = bitmap.clone();
bitmap.add(2);
assert_eq!(bitmap.cardinality(), 2);sourcepub fn and(&self, other: &Self) -> Self
pub fn and(&self, other: &Self) -> Self
And computes the intersection between two bitmaps and returns the result as a new bitmap
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[1]);
let bitmap2 = Bitmap::of(&[1, 2]);
let bitmap3 = bitmap1.and(&bitmap2);
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));sourcepub fn or(&self, other: &Self) -> Self
pub fn or(&self, other: &Self) -> Self
Or computes the union between two bitmaps and returns the result as a new bitmap
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let bitmap3 = bitmap1.or(&bitmap2);
assert_eq!(bitmap3.cardinality(), 2);
assert!(bitmap3.contains(15));
assert!(bitmap3.contains(25));sourcepub fn xor(&self, other: &Self) -> Self
pub fn xor(&self, other: &Self) -> Self
Computes the symmetric difference (xor) between two bitmaps and returns new bitmap.
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1.xor(&bitmap2);
assert_eq!(bitmap3.cardinality(), 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));sourcepub fn andnot(&self, other: &Self) -> Self
pub fn andnot(&self, other: &Self) -> Self
Computes the difference between two bitmaps and returns the result.
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1.andnot(&bitmap2);
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));sourcepub fn flip<R: RangeBounds<u32>>(&self, range: R) -> Self
pub fn flip<R: RangeBounds<u32>>(&self, range: R) -> Self
Negates the bits in the given range any integer present in this range and in the bitmap is removed. Returns result as a new bitmap.
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[4]);
let bitmap2 = bitmap1.flip(1..3);
assert_eq!(bitmap2.cardinality(), 3);
assert!(bitmap2.contains(1));
assert!(bitmap2.contains(2));
assert!(!bitmap2.contains(3));
assert!(bitmap2.contains(4));
let bitmap3 = bitmap1.flip(1..=5);
assert_eq!(bitmap3.iter().collect::<Vec<_>>(), [1, 2, 3, 5])sourcepub fn for_each<F, O>(&self, f: F) -> ControlFlow<O>
pub fn for_each<F, O>(&self, f: F) -> ControlFlow<O>
Iterate over the values in the bitmap in sorted order
If f returns Break, iteration will stop and the value will be returned,
Otherwise, iteration continues. If f never returns break, None is returned after all values are visited.
§Examples
use croaring::Bitmap;
use std::ops::ControlFlow;
let bitmap = Bitmap::of(&[1, 2, 3, 14, 20, 21, 100]);
let mut even_nums_under_50 = vec![];
let first_over_50 = bitmap.for_each(|value| {
if value > 50 {
return ControlFlow::Break(value);
}
if value % 2 == 0 {
even_nums_under_50.push(value);
}
ControlFlow::Continue(())
});
assert_eq!(even_nums_under_50, vec![2, 14, 20]);
assert_eq!(first_over_50, ControlFlow::Break(100));sourcepub fn to_vec(&self) -> Vec<u32>
Available on crate feature alloc only.
pub fn to_vec(&self) -> Vec<u32>
alloc only.Returns a vector containing all of the integers stored in the Bitmap in sorted order.
use croaring::Bitmap;
let bitmap = Bitmap::of(&[15, 25]);
assert_eq!(bitmap.to_vec(), [15, 25]);sourcepub fn get_serialized_size_in_bytes<S: Serializer>(&self) -> usize
pub fn get_serialized_size_in_bytes<S: Serializer>(&self) -> usize
Computes the serialized size in bytes of the Bitmap in format S.
sourcepub fn serialize<S: Serializer + NoAlign>(&self) -> Vec<u8>
Available on crate feature alloc only.
pub fn serialize<S: Serializer + NoAlign>(&self) -> Vec<u8>
alloc only.Serializes a bitmap to a slice of bytes in format S.
This function cannot be used with formats that require alignment, such as crate::Frozen.
§Examples
use croaring::{Bitmap, Portable};
let original_bitmap: Bitmap = (1..5).collect();
let serialized_buffer = original_bitmap.serialize::<Portable>();
let deserialized_bitmap = Bitmap::deserialize::<Portable>(&serialized_buffer);
assert_eq!(original_bitmap, deserialized_bitmap);use croaring::{Bitmap, Frozen};
let original_bitmap = Bitmap::of(&[1, 2, 3]);
// This will not compile, as `Frozen` requires alignment, and we can't guarantee that the
// start of the vec is aligned correctly
let serialized_buffer = original_bitmap.serialize::<Frozen>();sourcepub fn serialize_into_vec<'a, S: Serializer>(
&self,
dst: &'a mut Vec<u8>,
) -> &'a mut [u8] ⓘ
Available on crate feature alloc only.
pub fn serialize_into_vec<'a, S: Serializer>( &self, dst: &'a mut Vec<u8>, ) -> &'a mut [u8] ⓘ
alloc only.Serializes a bitmap to a slice of bytes in format S, re-using existing capacity
dst is not cleared, data is added after any existing data. Returns the added slice of dst.
Because of alignment requirements, the serialized data may not start at the beginning of
dst: the returned slice may not start at dst.as_ptr().
§Examples
use croaring::{Bitmap, Portable};
let original_bitmap_1: Bitmap = (1..5).collect();
let original_bitmap_2: Bitmap = (1..10).collect();
let mut data = Vec::new();
for bitmap in [original_bitmap_1, original_bitmap_2] {
data.clear();
let serialized: &[u8] = bitmap.serialize_into_vec::<Portable>(&mut data);
// do something with serialized data
}sourcepub fn try_serialize_into<'a, S: Serializer>(
&self,
dst: &'a mut [u8],
) -> Option<&'a mut [u8]>
pub fn try_serialize_into<'a, S: Serializer>( &self, dst: &'a mut [u8], ) -> Option<&'a mut [u8]>
Serializes a bitmap to a slice of bytes in format S
Returns the serialized data if the buffer was large enough, otherwise None.
See Self::get_serialized_size_in_bytes to determine the required buffer size.
Note also that some (crate::Frozen) formats require alignment, so the buffer size may need to
be larger than the serialized size.
See also Self::serialize_into_vec for a version that uses a Vec instead, or, for
advanced use-cases, see Serializer::try_serialize_into.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the Bitmap is empty. Faster than doing: bitmap.cardinality() == 0)
§Examples
use croaring::Bitmap;
let mut bitmap = Bitmap::new();
assert!(bitmap.is_empty());
bitmap.add(1);
assert!(!bitmap.is_empty());sourcepub fn is_subset(&self, other: &Self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
Return true if all the elements of Self are in &other.
§Examples
use croaring::Bitmap;
let bitmap1: Bitmap = (5..10).collect();
let bitmap2: Bitmap = (5..8).collect();
let bitmap3: Bitmap = (5..10).collect();
let bitmap4: Bitmap = (9..11).collect();
assert!(bitmap2.is_subset(&bitmap1));
assert!(bitmap3.is_subset(&bitmap1));
assert!(!bitmap4.is_subset(&bitmap1));sourcepub fn is_strict_subset(&self, other: &Self) -> bool
pub fn is_strict_subset(&self, other: &Self) -> bool
Return true if all the elements of Self are in &other and &other is strictly greater than Self.
§Examples
use croaring::Bitmap;
let bitmap1: Bitmap = (5..9).collect();
let bitmap2: Bitmap = (5..8).collect();
let bitmap3: Bitmap = (5..10).collect();
let bitmap4: Bitmap = (9..11).collect();
assert!(bitmap2.is_subset(&bitmap1));
assert!(!bitmap3.is_subset(&bitmap1));
assert!(!bitmap4.is_subset(&bitmap1));sourcepub fn intersect(&self, other: &Self) -> bool
pub fn intersect(&self, other: &Self) -> bool
Return true if Self and &other intersect
§Examples
use croaring::Bitmap;
let bitmap1: Bitmap = (1..5).collect();
let bitmap2: Bitmap = (5..9).collect();
let bitmap3: Bitmap = (3..7).collect();
assert_eq!(bitmap1.intersect(&bitmap2), false);
assert_eq!(bitmap1.intersect(&bitmap3), true);
assert_eq!(bitmap2.intersect(&bitmap3), true);sourcepub fn intersect_with_range<R: RangeBounds<u32>>(&self, range: R) -> bool
pub fn intersect_with_range<R: RangeBounds<u32>>(&self, range: R) -> bool
Check if a bitmap has any values set in range
§Examples
use croaring::Bitmap;
let bitmap = Bitmap::of(&[1, 100, 101, u32::MAX]);
assert!(bitmap.intersect_with_range(0..10));
assert!(!bitmap.intersect_with_range(2..100));
assert!(bitmap.intersect_with_range(999..=u32::MAX));
// Empty ranges
assert!(!bitmap.intersect_with_range(100..100));
assert!(!bitmap.intersect_with_range(100..0));sourcepub fn jaccard_index(&self, other: &Self) -> f64
pub fn jaccard_index(&self, other: &Self) -> f64
Return the Jaccard index between Self and &other
use croaring::Bitmap;
let bitmap1: Bitmap = (1..5).collect();
let bitmap2: Bitmap = (5..9).collect();
let bitmap3: Bitmap = (3..9).collect();
assert_eq!(bitmap1.jaccard_index(&bitmap2), 0.0);
assert_eq!(bitmap1.jaccard_index(&bitmap3), 0.25);
assert_eq!(bitmap2.jaccard_index(&bitmap3), 0.6666666666666666);sourcepub fn and_cardinality(&self, other: &Self) -> u64
pub fn and_cardinality(&self, other: &Self) -> u64
Return the size of the intersection between Self and &other
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[1]);
let bitmap2 = Bitmap::of(&[1, 2]);
assert_eq!(bitmap1.and_cardinality(&bitmap2), 1);sourcepub fn or_cardinality(&self, other: &Self) -> u64
pub fn or_cardinality(&self, other: &Self) -> u64
Return the size of the union between Self and &other
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
assert_eq!(bitmap1.or_cardinality(&bitmap2), 2);sourcepub fn andnot_cardinality(&self, other: &Self) -> u64
pub fn andnot_cardinality(&self, other: &Self) -> u64
Return the size of the difference between Self and &other
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
assert_eq!(bitmap1.andnot_cardinality(&bitmap2), 1);sourcepub fn xor_cardinality(&self, other: &Self) -> u64
pub fn xor_cardinality(&self, other: &Self) -> u64
Return the size of the symmetric difference between Self and &other
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
assert_eq!(bitmap1.xor_cardinality(&bitmap2), 2);sourcepub fn minimum(&self) -> Option<u32>
pub fn minimum(&self) -> Option<u32>
Returns the smallest value in the set.
Returns None if the set is empty.
§Examples
use croaring::Bitmap;
let mut bitmap: Bitmap = (5..10).collect();
let empty_bitmap: Bitmap = Bitmap::new();
assert_eq!(bitmap.minimum(), Some(5));
assert_eq!(empty_bitmap.minimum(), None);
bitmap.add(3);
assert_eq!(bitmap.minimum(), Some(3));sourcepub fn maximum(&self) -> Option<u32>
pub fn maximum(&self) -> Option<u32>
Returns the greatest value in the set.
Returns None if the set is empty.
§Examples
use croaring::Bitmap;
let mut bitmap: Bitmap = (5..10).collect();
let empty_bitmap: Bitmap = Bitmap::new();
assert_eq!(bitmap.maximum(), Some(9));
assert_eq!(empty_bitmap.maximum(), None);
bitmap.add(15);
assert_eq!(bitmap.maximum(), Some(15));sourcepub fn rank(&self, x: u32) -> u64
pub fn rank(&self, x: u32) -> u64
Rank returns the number of values smaller or equal to x.
For a similar function which also checks if x is in the set, see position.
§Examples
use croaring::Bitmap;
let mut bitmap: Bitmap = (5..10).collect();
assert_eq!(bitmap.rank(8), 4);
bitmap.add(15);
assert_eq!(bitmap.rank(11), 5);
assert_eq!(bitmap.rank(15), 6);sourcepub fn position(&self, x: u32) -> Option<u32>
pub fn position(&self, x: u32) -> Option<u32>
Returns the index of x in the given roaring bitmap.
If the roaring bitmap doesn’t contain x, this function will return None. The difference with the rank function is that this function will return None when x is not the element of roaring bitmap, but the rank function will return the the number of items less than x, and would require a call to contains to check if x is in the roaring bitmap.
§Examples
use croaring::Bitmap;
let mut bitmap: Bitmap = Bitmap::from_range(5..10);
assert_eq!(bitmap.position(4), None);
assert_eq!(bitmap.position(5), Some(0));
assert_eq!(bitmap.position(9), Some(4));
assert_eq!(bitmap.position(10), None);
assert_eq!(bitmap.position(9999), None);
// rank returns the number of values smaller or equal to x, so it always returns a value, and
// returns `position + 1` when x is contained in the bitmap.
assert_eq!(bitmap.rank(4), 0);
assert_eq!(bitmap.rank(5), 1);
assert_eq!(bitmap.rank(9), 5);
assert_eq!(bitmap.rank(10), 5);
assert_eq!(bitmap.rank(9999), 5);
let pos = bitmap.position(7).unwrap();
assert_eq!(bitmap.select(pos), Some(7));sourcepub fn select(&self, position: u32) -> Option<u32>
pub fn select(&self, position: u32) -> Option<u32>
Select returns the element having the designated position, if it exists
If the size of the roaring bitmap is strictly greater than pos, then this function returns element of given rank wrapped in Some. Otherwise, it returns None.
To do the inverse operation (given an element, find its position), use the position function, or the rank function.
Note that the rank function is inclusive: it returns the number of values
smaller or equal to x, when x is contained in the bitmap, it returns
position + 1.
§Examples
use croaring::Bitmap;
let bitmap: Bitmap = (5..10).collect();
assert_eq!(bitmap.select(0), Some(5));
assert_eq!(bitmap.select(1), Some(6));
assert_eq!(bitmap.select(2), Some(7));
assert_eq!(bitmap.select(3), Some(8));
assert_eq!(bitmap.select(4), Some(9));
assert_eq!(bitmap.select(5), None);sourcepub fn statistics(&self) -> Statistics
pub fn statistics(&self) -> Statistics
Returns statistics about the composition of a roaring bitmap.
§Examples
use croaring::Bitmap;
let mut bitmap: Bitmap = (1..100).collect();
let statistics = bitmap.statistics();
assert_eq!(statistics.n_containers, 1);
assert_eq!(statistics.n_array_containers, 1);
assert_eq!(statistics.n_run_containers, 0);
assert_eq!(statistics.n_bitset_containers, 0);
assert_eq!(statistics.n_values_array_containers, 99);
assert_eq!(statistics.n_values_run_containers, 0);
assert_eq!(statistics.n_values_bitset_containers, 0);
assert_eq!(statistics.n_bytes_array_containers, 198);
assert_eq!(statistics.n_bytes_run_containers, 0);
assert_eq!(statistics.n_bytes_bitset_containers, 0);
assert_eq!(statistics.max_value, 99);
assert_eq!(statistics.min_value, 1);
assert_eq!(statistics.cardinality, 99);
bitmap.run_optimize();
let statistics = bitmap.statistics();
assert_eq!(statistics.n_containers, 1);
assert_eq!(statistics.n_array_containers, 0);
assert_eq!(statistics.n_run_containers, 1);
assert_eq!(statistics.n_bitset_containers, 0);
assert_eq!(statistics.n_values_array_containers, 0);
assert_eq!(statistics.n_values_run_containers, 99);
assert_eq!(statistics.n_values_bitset_containers, 0);
assert_eq!(statistics.n_bytes_array_containers, 0);
assert_eq!(statistics.n_bytes_run_containers, 6);
assert_eq!(statistics.n_bytes_bitset_containers, 0);
assert_eq!(statistics.max_value, 99);
assert_eq!(statistics.min_value, 1);
assert_eq!(statistics.cardinality, 99);sourcepub fn to_bitset(&self) -> Option<Bitset>
pub fn to_bitset(&self) -> Option<Bitset>
Store the bitmap to a bitset
This can be useful for those who need the performance and simplicity of a standard bitset.
§Errors
This function will return None on allocation failure
§Examples
use croaring::Bitmap;
let bitmap = Bitmap::from_range(0..100);
let bitset = bitmap.to_bitset().unwrap();
assert_eq!(bitset.count(), 100);sourcepub fn iter(&self) -> BitmapIterator<'_> ⓘ
pub fn iter(&self) -> BitmapIterator<'_> ⓘ
Returns an iterator over each value stored in the bitmap. Returned values are ordered in ascending order.
§Examples
use croaring::Bitmap;
let mut bitmap = Bitmap::new();
bitmap.add(4);
bitmap.add(3);
bitmap.add(2);
let mut iterator = bitmap.iter();
assert_eq!(iterator.next(), Some(2));
assert_eq!(iterator.next(), Some(3));
assert_eq!(iterator.next(), Some(4));
assert_eq!(iterator.next(), None);sourcepub fn cursor(&self) -> BitmapCursor<'_>
pub fn cursor(&self) -> BitmapCursor<'_>
Returns a cursor pointing at the first value in the bitmap.
See BitmapCursor for more details.
sourcepub fn cursor_to_last(&self) -> BitmapCursor<'_>
pub fn cursor_to_last(&self) -> BitmapCursor<'_>
Returns a cursor pointing at the last value in the bitmap.
See BitmapCursor for more details.
Trait Implementations§
source§impl BitAnd<&Bitmap> for &BitmapView<'_>
impl BitAnd<&Bitmap> for &BitmapView<'_>
source§fn bitand(self, other: &Bitmap) -> Bitmap
fn bitand(self, other: &Bitmap) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd<&Bitmap> for BitmapView<'_>
impl BitAnd<&Bitmap> for BitmapView<'_>
source§fn bitand(self, other: &Bitmap) -> Bitmap
fn bitand(self, other: &Bitmap) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd<&BitmapView<'_>> for &BitmapView<'_>
impl BitAnd<&BitmapView<'_>> for &BitmapView<'_>
source§fn bitand(self, other: &BitmapView<'_>) -> Bitmap
fn bitand(self, other: &BitmapView<'_>) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd<&BitmapView<'_>> for BitmapView<'_>
impl BitAnd<&BitmapView<'_>> for BitmapView<'_>
source§fn bitand(self, other: &BitmapView<'_>) -> Bitmap
fn bitand(self, other: &BitmapView<'_>) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd<Bitmap> for &BitmapView<'_>
impl BitAnd<Bitmap> for &BitmapView<'_>
source§fn bitand(self, other: Bitmap) -> Bitmap
fn bitand(self, other: Bitmap) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd<Bitmap> for BitmapView<'_>
impl BitAnd<Bitmap> for BitmapView<'_>
source§fn bitand(self, other: Bitmap) -> Bitmap
fn bitand(self, other: Bitmap) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd<BitmapView<'_>> for &BitmapView<'_>
impl BitAnd<BitmapView<'_>> for &BitmapView<'_>
source§fn bitand(self, other: BitmapView<'_>) -> Bitmap
fn bitand(self, other: BitmapView<'_>) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAnd for BitmapView<'_>
impl BitAnd for BitmapView<'_>
source§fn bitand(self, other: BitmapView<'_>) -> Bitmap
fn bitand(self, other: BitmapView<'_>) -> Bitmap
Syntactic sugar for .and
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::new();
bitmap1.add(1);
let mut bitmap2 = Bitmap::new();
bitmap2.add(1);
bitmap2.add(2);
let bitmap3 = bitmap1 & bitmap2;
assert!(bitmap3.contains(1));
assert!(!bitmap3.contains(2));source§impl BitAndAssign<&BitmapView<'_>> for Bitmap
impl BitAndAssign<&BitmapView<'_>> for Bitmap
source§fn bitand_assign(&mut self, other: &BitmapView<'_>)
fn bitand_assign(&mut self, other: &BitmapView<'_>)
Syntactic sugar for .and_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let mut bitmap3 = Bitmap::of(&[15]);
let bitmap4 = Bitmap::of(&[15, 25]);
bitmap1 &= bitmap2;
assert!(bitmap1.cardinality() == 0);
assert!(!bitmap1.contains(15));
assert!(!bitmap1.contains(25));
bitmap3 &= bitmap4;
assert!(bitmap3.cardinality() == 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));source§impl BitAndAssign<BitmapView<'_>> for Bitmap
impl BitAndAssign<BitmapView<'_>> for Bitmap
source§fn bitand_assign(&mut self, other: BitmapView<'_>)
fn bitand_assign(&mut self, other: BitmapView<'_>)
Syntactic sugar for .and_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let mut bitmap3 = Bitmap::of(&[15]);
let bitmap4 = Bitmap::of(&[15, 25]);
bitmap1 &= bitmap2;
assert!(bitmap1.cardinality() == 0);
assert!(!bitmap1.contains(15));
assert!(!bitmap1.contains(25));
bitmap3 &= bitmap4;
assert!(bitmap3.cardinality() == 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));source§impl BitOr<&Bitmap> for &BitmapView<'_>
impl BitOr<&Bitmap> for &BitmapView<'_>
source§impl BitOr<&Bitmap> for BitmapView<'_>
impl BitOr<&Bitmap> for BitmapView<'_>
source§impl BitOr<&BitmapView<'_>> for &BitmapView<'_>
impl BitOr<&BitmapView<'_>> for &BitmapView<'_>
source§fn bitor(self, other: &BitmapView<'_>) -> Bitmap
fn bitor(self, other: &BitmapView<'_>) -> Bitmap
Syntatic sugar for .or
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let bitmap3 = bitmap1 | bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(bitmap3.contains(25));source§impl BitOr<&BitmapView<'_>> for BitmapView<'_>
impl BitOr<&BitmapView<'_>> for BitmapView<'_>
source§fn bitor(self, other: &BitmapView<'_>) -> Bitmap
fn bitor(self, other: &BitmapView<'_>) -> Bitmap
Syntatic sugar for .or
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let bitmap3 = bitmap1 | bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(bitmap3.contains(25));source§impl BitOr<Bitmap> for &BitmapView<'_>
impl BitOr<Bitmap> for &BitmapView<'_>
source§impl BitOr<Bitmap> for BitmapView<'_>
impl BitOr<Bitmap> for BitmapView<'_>
source§impl BitOr<BitmapView<'_>> for &BitmapView<'_>
impl BitOr<BitmapView<'_>> for &BitmapView<'_>
source§fn bitor(self, other: BitmapView<'_>) -> Bitmap
fn bitor(self, other: BitmapView<'_>) -> Bitmap
Syntatic sugar for .or
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let bitmap3 = bitmap1 | bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(bitmap3.contains(25));source§impl BitOr for BitmapView<'_>
impl BitOr for BitmapView<'_>
source§fn bitor(self, other: BitmapView<'_>) -> Bitmap
fn bitor(self, other: BitmapView<'_>) -> Bitmap
Syntatic sugar for .or
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
let bitmap3 = bitmap1 | bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(bitmap3.contains(25));source§impl BitOrAssign<&BitmapView<'_>> for Bitmap
impl BitOrAssign<&BitmapView<'_>> for Bitmap
source§fn bitor_assign(&mut self, other: &BitmapView<'_>)
fn bitor_assign(&mut self, other: &BitmapView<'_>)
Syntatic sugar for .or_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
bitmap1 |= bitmap2;
assert!(bitmap1.cardinality() == 2);
assert!(bitmap1.contains(15));
assert!(bitmap1.contains(25));source§impl BitOrAssign<BitmapView<'_>> for Bitmap
impl BitOrAssign<BitmapView<'_>> for Bitmap
source§fn bitor_assign(&mut self, other: BitmapView<'_>)
fn bitor_assign(&mut self, other: BitmapView<'_>)
Syntatic sugar for .or_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15]);
let bitmap2 = Bitmap::of(&[25]);
bitmap1 |= bitmap2;
assert!(bitmap1.cardinality() == 2);
assert!(bitmap1.contains(15));
assert!(bitmap1.contains(25));source§impl BitXor<&Bitmap> for &BitmapView<'_>
impl BitXor<&Bitmap> for &BitmapView<'_>
source§fn bitxor(self, other: &Bitmap) -> Bitmap
fn bitxor(self, other: &Bitmap) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor<&Bitmap> for BitmapView<'_>
impl BitXor<&Bitmap> for BitmapView<'_>
source§fn bitxor(self, other: &Bitmap) -> Bitmap
fn bitxor(self, other: &Bitmap) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor<&BitmapView<'_>> for &BitmapView<'_>
impl BitXor<&BitmapView<'_>> for &BitmapView<'_>
source§fn bitxor(self, other: &BitmapView<'_>) -> Bitmap
fn bitxor(self, other: &BitmapView<'_>) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor<&BitmapView<'_>> for BitmapView<'_>
impl BitXor<&BitmapView<'_>> for BitmapView<'_>
source§fn bitxor(self, other: &BitmapView<'_>) -> Bitmap
fn bitxor(self, other: &BitmapView<'_>) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor<Bitmap> for &BitmapView<'_>
impl BitXor<Bitmap> for &BitmapView<'_>
source§fn bitxor(self, other: Bitmap) -> Bitmap
fn bitxor(self, other: Bitmap) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor<Bitmap> for BitmapView<'_>
impl BitXor<Bitmap> for BitmapView<'_>
source§fn bitxor(self, other: Bitmap) -> Bitmap
fn bitxor(self, other: Bitmap) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor<BitmapView<'_>> for &BitmapView<'_>
impl BitXor<BitmapView<'_>> for &BitmapView<'_>
source§fn bitxor(self, other: BitmapView<'_>) -> Bitmap
fn bitxor(self, other: BitmapView<'_>) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXor for BitmapView<'_>
impl BitXor for BitmapView<'_>
source§fn bitxor(self, other: BitmapView<'_>) -> Bitmap
fn bitxor(self, other: BitmapView<'_>) -> Bitmap
Syntatic sugar for .xor
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 ^ bitmap2;
assert!(bitmap3.cardinality() == 2);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(bitmap3.contains(35));source§impl BitXorAssign<&BitmapView<'_>> for Bitmap
impl BitXorAssign<&BitmapView<'_>> for Bitmap
source§fn bitxor_assign(&mut self, other: &BitmapView<'_>)
fn bitxor_assign(&mut self, other: &BitmapView<'_>)
Syntatic sugar for .xor_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
bitmap1 ^= bitmap2;
assert!(bitmap1.cardinality() == 2);
assert!(bitmap1.contains(15));
assert!(!bitmap1.contains(25));
assert!(bitmap1.contains(35));source§impl BitXorAssign<BitmapView<'_>> for Bitmap
impl BitXorAssign<BitmapView<'_>> for Bitmap
source§fn bitxor_assign(&mut self, other: BitmapView<'_>)
fn bitxor_assign(&mut self, other: BitmapView<'_>)
Syntatic sugar for .xor_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
bitmap1 ^= bitmap2;
assert!(bitmap1.cardinality() == 2);
assert!(bitmap1.contains(15));
assert!(!bitmap1.contains(25));
assert!(bitmap1.contains(35));source§impl<'a> Debug for BitmapView<'a>
impl<'a> Debug for BitmapView<'a>
source§impl<'a> Deref for BitmapView<'a>
impl<'a> Deref for BitmapView<'a>
source§impl<'a> Drop for BitmapView<'a>
impl<'a> Drop for BitmapView<'a>
source§impl PartialEq<Bitmap> for BitmapView<'_>
impl PartialEq<Bitmap> for BitmapView<'_>
source§impl PartialEq<BitmapView<'_>> for Bitmap
impl PartialEq<BitmapView<'_>> for Bitmap
source§impl PartialEq for BitmapView<'_>
impl PartialEq for BitmapView<'_>
source§impl Sub<&Bitmap> for &BitmapView<'_>
impl Sub<&Bitmap> for &BitmapView<'_>
source§fn sub(self, other: &Bitmap) -> Bitmap
fn sub(self, other: &Bitmap) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub<&Bitmap> for BitmapView<'_>
impl Sub<&Bitmap> for BitmapView<'_>
source§fn sub(self, other: &Bitmap) -> Bitmap
fn sub(self, other: &Bitmap) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub<&BitmapView<'_>> for &BitmapView<'_>
impl Sub<&BitmapView<'_>> for &BitmapView<'_>
source§fn sub(self, other: &BitmapView<'_>) -> Bitmap
fn sub(self, other: &BitmapView<'_>) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub<&BitmapView<'_>> for BitmapView<'_>
impl Sub<&BitmapView<'_>> for BitmapView<'_>
source§fn sub(self, other: &BitmapView<'_>) -> Bitmap
fn sub(self, other: &BitmapView<'_>) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub<Bitmap> for &BitmapView<'_>
impl Sub<Bitmap> for &BitmapView<'_>
source§fn sub(self, other: Bitmap) -> Bitmap
fn sub(self, other: Bitmap) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub<Bitmap> for BitmapView<'_>
impl Sub<Bitmap> for BitmapView<'_>
source§fn sub(self, other: Bitmap) -> Bitmap
fn sub(self, other: Bitmap) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub<BitmapView<'_>> for &BitmapView<'_>
impl Sub<BitmapView<'_>> for &BitmapView<'_>
source§fn sub(self, other: BitmapView<'_>) -> Bitmap
fn sub(self, other: BitmapView<'_>) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl Sub for BitmapView<'_>
impl Sub for BitmapView<'_>
source§fn sub(self, other: BitmapView<'_>) -> Bitmap
fn sub(self, other: BitmapView<'_>) -> Bitmap
Syntatic sugar for .andnot
§Examples
use croaring::Bitmap;
let bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
let bitmap3 = bitmap1 - bitmap2;
assert_eq!(bitmap3.cardinality(), 1);
assert!(bitmap3.contains(15));
assert!(!bitmap3.contains(25));
assert!(!bitmap3.contains(35));source§impl SubAssign<&BitmapView<'_>> for Bitmap
impl SubAssign<&BitmapView<'_>> for Bitmap
source§fn sub_assign(&mut self, other: &BitmapView<'_>)
fn sub_assign(&mut self, other: &BitmapView<'_>)
Syntatic sugar for .andnot_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
bitmap1 -= bitmap2;
assert_eq!(bitmap1.cardinality(), 1);
assert!(bitmap1.contains(15));
assert!(!bitmap1.contains(25));
assert!(!bitmap1.contains(35));source§impl SubAssign<BitmapView<'_>> for Bitmap
impl SubAssign<BitmapView<'_>> for Bitmap
source§fn sub_assign(&mut self, other: BitmapView<'_>)
fn sub_assign(&mut self, other: BitmapView<'_>)
Syntatic sugar for .andnot_inplace
§Examples
use croaring::Bitmap;
let mut bitmap1 = Bitmap::of(&[15, 25]);
let bitmap2 = Bitmap::of(&[25, 35]);
bitmap1 -= bitmap2;
assert_eq!(bitmap1.cardinality(), 1);
assert!(bitmap1.contains(15));
assert!(!bitmap1.contains(25));
assert!(!bitmap1.contains(35));