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());
Implementations
impl RoaringBitmap
[src]
impl RoaringBitmap
[src]pub fn is_disjoint(&self, other: &Self) -> bool
[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);
pub fn is_subset(&self, other: &Self) -> bool
[src]
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);
pub fn is_superset(&self, other: &Self) -> bool
[src]
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]
impl RoaringBitmap
[src]pub fn new() -> RoaringBitmap
[src]
Creates an empty RoaringBitmap
.
Examples
use roaring::RoaringBitmap; let mut rb = RoaringBitmap::new();
pub fn insert(&mut self, value: u32) -> bool
[src]
Adds a value to the set.
Returns whether the value was absent from 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);
pub fn insert_range(&mut self, range: Range<u64>) -> u64
[src]
Inserts a range of values from the set specific as [start..end). Returns the number of inserted values.
Note that due to the exclusive end this functions take indexes as u64 but you still can’t index past 2**32 (u32::MAX + 1).
Safety
This function panics if the range upper bound exceeds u32::MAX
.
Examples
use roaring::RoaringBitmap; let mut rb = RoaringBitmap::new(); rb.insert_range(2..4); assert!(rb.contains(2)); assert!(rb.contains(3)); assert!(!rb.contains(4));
pub fn push(&mut self, value: u32) -> bool
[src]
Pushes value
in the bitmap only if it is greater than the current maximum value.
Returns whether the value was inserted.
Examples
use roaring::RoaringBitmap; let mut rb = RoaringBitmap::new(); assert!(rb.push(1)); assert!(rb.push(3)); assert_eq!(rb.push(3), false); assert!(rb.push(5)); assert_eq!(rb.iter().collect::<Vec<u32>>(), vec![1, 3, 5]);
pub fn remove(&mut self, value: u32) -> bool
[src]
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);
pub fn remove_range(&mut self, range: Range<u64>) -> u64
[src]
Removes a range of values from the set specific as [start..end). Returns the number of removed values.
Note that due to the exclusive end this functions take indexes as u64 but you still can’t index past 2**32 (u32::MAX + 1).
Examples
use roaring::RoaringBitmap; let mut rb = RoaringBitmap::new(); rb.insert(2); rb.insert(3); assert_eq!(rb.remove_range(2..4), 2);
pub fn contains(&self, value: u32) -> bool
[src]
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);
pub fn clear(&mut self)
[src]
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);
pub fn is_empty(&self) -> bool
[src]
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);
pub fn len(&self) -> u64
[src]
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);
pub fn min(&self) -> Option<u32>
[src]
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));
pub fn max(&self) -> Option<u32>
[src]
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]
impl RoaringBitmap
[src]pub fn iter(&self) -> Iter<'_>ⓘ
[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 = (1..3).collect::<RoaringBitmap>(); 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]
impl RoaringBitmap
[src]pub fn from_sorted_iter<I: IntoIterator<Item = u32>>(
iterator: I
) -> RoaringBitmap
[src]
iterator: I
) -> RoaringBitmap
Create the set from a sorted iterator. Values must be sorted.
This method can be faster than from_iter
because it skips the binary searches.
Examples
use roaring::RoaringBitmap; let mut rb = RoaringBitmap::from_sorted_iter(0..10); assert_eq!(rb.iter().collect::<Vec<u32>>(), (0..10).collect::<Vec<u32>>());
pub fn append<I: IntoIterator<Item = u32>>(&mut self, iterator: I)
[src]
Extend the set with a sorted iterator. All value of the iterator must be strictly bigger than the max element contained in the set.
This method can be faster than extend
because it skips the binary searches.
Examples
use roaring::RoaringBitmap; let mut rb = RoaringBitmap::new(); rb.append(0..10); assert_eq!(rb.iter().collect::<Vec<u32>>(), (0..10).collect::<Vec<u32>>());
impl RoaringBitmap
[src]
impl RoaringBitmap
[src]pub fn union_with(&mut self, other: &RoaringBitmap)
[src]
Please use the BitOrAssign::bitor_assign
(|=
) ops method instead
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 |= 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);
pub fn intersect_with(&mut self, other: &RoaringBitmap)
[src]
Please use the BitAndAssign::bitand_assign
(&=
) ops method instead
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 &= 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);
pub fn difference_with(&mut self, other: &RoaringBitmap)
[src]
Please use the SubAssign::sub_assign
(-=
) ops method instead
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 -= 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);
pub fn symmetric_difference_with(&mut self, other: &RoaringBitmap)
[src]
Please use the BitXorAssign::bitxor_assign
(^=
) ops method instead
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 ^= 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]
impl RoaringBitmap
[src]pub fn serialized_size(&self) -> usize
[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(&bytes[..]).unwrap(); assert_eq!(rb1, rb2);
pub fn serialize_into<W: Write>(&self, writer: W) -> Result<()>
[src]
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(&bytes[..]).unwrap(); assert_eq!(rb1, rb2);
pub fn deserialize_from<R: Read>(reader: R) -> Result<RoaringBitmap>
[src]
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(&bytes[..]).unwrap(); assert_eq!(rb1, rb2);
Trait Implementations
impl BitAnd<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl BitAnd<&'_ RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the &
operator.
fn bitand(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
An intersection
between two sets.
impl BitAnd<&'_ RoaringBitmap> for &RoaringBitmap
[src]
impl BitAnd<&'_ RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the &
operator.
fn bitand(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
An intersection
between two sets.
impl BitAnd<RoaringBitmap> for RoaringBitmap
[src]
impl BitAnd<RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the &
operator.
fn bitand(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
An intersection
between two sets.
impl BitAnd<RoaringBitmap> for &RoaringBitmap
[src]
impl BitAnd<RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the &
operator.
fn bitand(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
An intersection
between two sets.
impl BitAndAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl BitAndAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]fn bitand_assign(&mut self, rhs: &RoaringBitmap)
[src]
An intersection
between two sets.
impl BitAndAssign<RoaringBitmap> for RoaringBitmap
[src]
impl BitAndAssign<RoaringBitmap> for RoaringBitmap
[src]fn bitand_assign(&mut self, rhs: RoaringBitmap)
[src]
An intersection
between two sets.
impl BitOr<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl BitOr<&'_ RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the |
operator.
fn bitor(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
An union
between two sets.
impl BitOr<&'_ RoaringBitmap> for &RoaringBitmap
[src]
impl BitOr<&'_ RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the |
operator.
fn bitor(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
An union
between two sets.
impl BitOr<RoaringBitmap> for RoaringBitmap
[src]
impl BitOr<RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the |
operator.
fn bitor(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
An union
between two sets.
impl BitOr<RoaringBitmap> for &RoaringBitmap
[src]
impl BitOr<RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the |
operator.
fn bitor(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
An union
between two sets.
impl BitOrAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl BitOrAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]fn bitor_assign(&mut self, rhs: &RoaringBitmap)
[src]
An union
between two sets.
impl BitOrAssign<RoaringBitmap> for RoaringBitmap
[src]
impl BitOrAssign<RoaringBitmap> for RoaringBitmap
[src]fn bitor_assign(&mut self, rhs: RoaringBitmap)
[src]
An union
between two sets.
impl BitXor<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl BitXor<&'_ RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
A symmetric difference
between two sets.
impl BitXor<&'_ RoaringBitmap> for &RoaringBitmap
[src]
impl BitXor<&'_ RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
A symmetric difference
between two sets.
impl BitXor<RoaringBitmap> for RoaringBitmap
[src]
impl BitXor<RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
A symmetric difference
between two sets.
impl BitXor<RoaringBitmap> for &RoaringBitmap
[src]
impl BitXor<RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
A symmetric difference
between two sets.
impl BitXorAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl BitXorAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]fn bitxor_assign(&mut self, rhs: &RoaringBitmap)
[src]
A symmetric difference
between two sets.
impl BitXorAssign<RoaringBitmap> for RoaringBitmap
[src]
impl BitXorAssign<RoaringBitmap> for RoaringBitmap
[src]fn bitxor_assign(&mut self, rhs: RoaringBitmap)
[src]
A symmetric difference
between two sets.
impl Clone for RoaringBitmap
[src]
impl Clone for RoaringBitmap
[src]fn clone(&self) -> RoaringBitmap
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Default for RoaringBitmap
[src]
impl Default for RoaringBitmap
[src]fn default() -> RoaringBitmap
[src]
impl Extend<u32> for RoaringBitmap
[src]
impl Extend<u32> for RoaringBitmap
[src]fn extend<I: IntoIterator<Item = u32>>(&mut self, iterator: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl FromIterator<u32> for RoaringBitmap
[src]
impl FromIterator<u32> for RoaringBitmap
[src]fn from_iter<I: IntoIterator<Item = u32>>(iterator: I) -> RoaringBitmap
[src]
impl<'a> IntoIterator for &'a RoaringBitmap
[src]
impl<'a> IntoIterator for &'a RoaringBitmap
[src]impl IntoIterator for RoaringBitmap
[src]
impl IntoIterator for RoaringBitmap
[src]impl PartialEq<RoaringBitmap> for RoaringBitmap
[src]
impl PartialEq<RoaringBitmap> for RoaringBitmap
[src]fn eq(&self, other: &RoaringBitmap) -> bool
[src]
fn ne(&self, other: &RoaringBitmap) -> bool
[src]
impl StructuralPartialEq for RoaringBitmap
[src]
impl StructuralPartialEq for RoaringBitmap
[src]impl Sub<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl Sub<&'_ RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the -
operator.
fn sub(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
A difference
between two sets.
impl Sub<&'_ RoaringBitmap> for &RoaringBitmap
[src]
impl Sub<&'_ RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the -
operator.
fn sub(self, rhs: &RoaringBitmap) -> RoaringBitmap
[src]
A difference
between two sets.
impl Sub<RoaringBitmap> for RoaringBitmap
[src]
impl Sub<RoaringBitmap> for RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the -
operator.
fn sub(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
A difference
between two sets.
impl Sub<RoaringBitmap> for &RoaringBitmap
[src]
impl Sub<RoaringBitmap> for &RoaringBitmap
[src]type Output = RoaringBitmap
The resulting type after applying the -
operator.
fn sub(self, rhs: RoaringBitmap) -> RoaringBitmap
[src]
A difference
between two sets.
impl SubAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]
impl SubAssign<&'_ RoaringBitmap> for RoaringBitmap
[src]fn sub_assign(&mut self, rhs: &RoaringBitmap)
[src]
A difference
between two sets.
impl SubAssign<RoaringBitmap> for RoaringBitmap
[src]
impl SubAssign<RoaringBitmap> for RoaringBitmap
[src]fn sub_assign(&mut self, rhs: RoaringBitmap)
[src]
A difference
between two sets.
Auto Trait Implementations
impl RefUnwindSafe for RoaringBitmap
impl RefUnwindSafe for RoaringBitmap
impl Send for RoaringBitmap
impl Send for RoaringBitmap
impl Sync for RoaringBitmap
impl Sync for RoaringBitmap
impl Unpin for RoaringBitmap
impl Unpin for RoaringBitmap
impl UnwindSafe for RoaringBitmap
impl UnwindSafe for RoaringBitmap