Struct roaring::treemap::RoaringTreemap [−][src]
A compressed bitmap with u64 values.
Implemented as a BTreeMap
of RoaringBitmap
s.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::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 RoaringTreemap
[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::RoaringTreemap; let mut rb1 = RoaringTreemap::new(); let mut rb2 = RoaringTreemap::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::RoaringTreemap; let mut rb1 = RoaringTreemap::new(); let mut rb2 = RoaringTreemap::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::RoaringTreemap; let mut rb1 = RoaringTreemap::new(); let mut rb2 = RoaringTreemap::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 RoaringTreemap
[src]
pub fn new() -> RoaringTreemap
[src]
Creates an empty RoaringTreemap
.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new();
pub fn insert(&mut self, value: u64) -> bool
[src]
Adds a value to the set. Returns true
if the value was not already present in the set.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new(); assert_eq!(rb.insert(3), true); assert_eq!(rb.insert(3), false); assert_eq!(rb.contains(3), true);
pub fn push(&mut self, value: u64)
[src]
Adds a value to the set. The value must be greater or equal to the maximum value in the set.
This method can be faster than insert
because it skips the binary searches.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new(); rb.push(1); rb.push(3); rb.push(5); assert_eq!(rb.iter().collect::<Vec<u64>>(), vec![1, 3, 5]);
pub fn remove(&mut self, value: u64) -> bool
[src]
Removes a value from the set. Returns true
if the value was present in the set.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::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 you can't remove the item at the last index (u64::MAX) using this function!
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new(); rb.insert(2); rb.insert(3); assert_eq!(rb.remove_range(2..4), 2);
pub fn contains(&self, value: u64) -> bool
[src]
Returns true
if this set contains the specified integer.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::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::RoaringTreemap; let mut rb = RoaringTreemap::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::RoaringTreemap; let mut rb = RoaringTreemap::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::RoaringTreemap; let mut rb = RoaringTreemap::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<u64>
[src]
Returns the minimum value in the set (if the set is non-empty).
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new(); assert_eq!(rb.min(), None); rb.insert(3); rb.insert(4); assert_eq!(rb.min(), Some(3));
pub fn max(&self) -> Option<u64>
[src]
Returns the maximum value in the set (if the set is non-empty).
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new(); assert_eq!(rb.max(), None); rb.insert(3); rb.insert(4); assert_eq!(rb.max(), Some(4));
impl RoaringTreemap
[src]
pub fn iter(&self) -> Iter<'_>ⓘ
[src]
Iterator over each value stored in the RoaringTreemap, guarantees values are ordered by value.
Examples
use roaring::RoaringTreemap; use std::iter::FromIterator; let bitmap = (1..3).collect::<RoaringTreemap>(); let mut iter = bitmap.iter(); assert_eq!(iter.next(), Some(1)); assert_eq!(iter.next(), Some(2)); assert_eq!(iter.next(), None);
pub fn bitmaps(&self) -> BitmapIter<'_>
[src]
Iterator over pairs of partition number and the corresponding RoaringBitmap. The partition number is defined by the 32 most significant bits of the bit index.
Examples
use roaring::{RoaringBitmap, RoaringTreemap}; use std::iter::FromIterator; let original = (0..6000).collect::<RoaringTreemap>(); let mut bitmaps = original.bitmaps(); assert_eq!(bitmaps.next(), Some((0, &(0..6000).collect::<RoaringBitmap>()))); assert_eq!(bitmaps.next(), None);
pub fn from_bitmaps<I: IntoIterator<Item = (u32, RoaringBitmap)>>(
iterator: I
) -> Self
[src]
iterator: I
) -> Self
Construct a RoaringTreemap from an iterator of partition number and RoaringBitmap pairs. The partition number is defined by the 32 most significant bits of the bit index. Note that repeated partitions, if present, will replace previously set partitions.
Examples
use roaring::RoaringTreemap; use std::iter::FromIterator; let original = (0..6000).collect::<RoaringTreemap>(); let clone = RoaringTreemap::from_bitmaps(original.bitmaps().map(|(p, b)| (p, b.clone()))); assert_eq!(clone, original);
impl RoaringTreemap
[src]
pub fn from_sorted_iter<I: IntoIterator<Item = u64>>(
iterator: I
) -> RoaringTreemap
[src]
iterator: I
) -> RoaringTreemap
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::RoaringTreemap; let mut rb = RoaringTreemap::from_sorted_iter(0..10); assert_eq!(rb.iter().collect::<Vec<u64>>(), (0..10).collect::<Vec<u64>>());
pub fn append<I: IntoIterator<Item = u64>>(&mut self, iterator: I)
[src]
Extend the set with a sorted iterator. All value of the iterator must be greater or equal than the max element contained in the set.
This method can be faster than extend
because it skips the binary searches.
Examples
use roaring::RoaringTreemap; let mut rb = RoaringTreemap::new(); rb.append(0..10); assert_eq!(rb.iter().collect::<Vec<u64>>(), (0..10).collect::<Vec<u64>>());
impl RoaringTreemap
[src]
pub fn union_with(&mut self, other: &RoaringTreemap)
[src]
Unions in-place with the specified other bitmap.
Examples
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..5).collect(); let rb3: RoaringTreemap = (1..5).collect(); rb1.union_with(&rb2); assert_eq!(rb1, rb3);
Can also be done via the BitOr
operator.
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..5).collect(); let rb3: RoaringTreemap = (1..5).collect(); let rb1 = rb1 | rb2; assert_eq!(rb1, rb3);
pub fn intersect_with(&mut self, other: &RoaringTreemap)
[src]
Intersects in-place with the specified other bitmap.
Examples
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..5).collect(); let rb3: RoaringTreemap = (3..4).collect(); rb1.intersect_with(&rb2); assert_eq!(rb1, rb3);
Can also be done via the BitAnd
operator.
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..5).collect(); let rb3: RoaringTreemap = (3..4).collect(); let rb1 = rb1 & rb2; assert_eq!(rb1, rb3);
pub fn difference_with(&mut self, other: &RoaringTreemap)
[src]
Removes all values in the specified other bitmap from self, in-place.
Examples
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..5).collect(); let rb3: RoaringTreemap = (1..3).collect(); rb1.difference_with(&rb2); assert_eq!(rb1, rb3);
Can also be done via the Sub
operator.
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..5).collect(); let rb3: RoaringTreemap = (1..3).collect(); let rb1 = rb1 - rb2; assert_eq!(rb1, rb3);
pub fn symmetric_difference_with(&mut self, other: &RoaringTreemap)
[src]
Replaces this bitmap with one that is equivalent to self XOR other
.
Examples
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..6).collect(); let rb3: RoaringTreemap = (1..3).chain(4..6).collect(); rb1.symmetric_difference_with(&rb2); assert_eq!(rb1, rb3);
Can also be done via the BitXor
operator.
use roaring::RoaringTreemap; let mut rb1: RoaringTreemap = (1..4).collect(); let rb2: RoaringTreemap = (3..6).collect(); let rb3: RoaringTreemap = (1..3).chain(4..6).collect(); let rb1 = rb1 ^ rb2; assert_eq!(rb1, rb3);
impl RoaringTreemap
[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::RoaringTreemap; let rb1: RoaringTreemap = (1..4).collect(); let mut bytes = Vec::with_capacity(rb1.serialized_size()); rb1.serialize_into(&mut bytes).unwrap(); let rb2 = RoaringTreemap::deserialize_from(&mut &bytes[..]).unwrap(); assert_eq!(rb1, rb2);
pub fn serialize_into<W: Write>(&self, writer: W) -> Result<()>
[src]
Serialize this bitmap. This is compatible with the official C/C++, Java and Go implementations.
Examples
use roaring::RoaringTreemap; let rb1: RoaringTreemap = (1..4).collect(); let mut bytes = vec![]; rb1.serialize_into(&mut bytes).unwrap(); let rb2 = RoaringTreemap::deserialize_from(&mut &bytes[..]).unwrap(); assert_eq!(rb1, rb2);
pub fn deserialize_from<R: Read>(reader: R) -> Result<Self>
[src]
Deserialize a bitmap into memory. This is compatible with the official C/C++, Java and Go implementations.
Examples
use roaring::RoaringTreemap; let rb1: RoaringTreemap = (1..4).collect(); let mut bytes = vec![]; rb1.serialize_into(&mut bytes).unwrap(); let rb2 = RoaringTreemap::deserialize_from(&mut &bytes[..]).unwrap(); assert_eq!(rb1, rb2);
Trait Implementations
impl<'a> BitAnd<&'a RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl<'a, 'b> BitAnd<&'a RoaringTreemap> for &'b RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl BitAnd<RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the &
operator.
fn bitand(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> BitAnd<RoaringTreemap> for &'a RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the &
operator.
fn bitand(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> BitAndAssign<&'a RoaringTreemap> for RoaringTreemap
[src]
fn bitand_assign(&mut self, rhs: &'a RoaringTreemap)
[src]
impl BitAndAssign<RoaringTreemap> for RoaringTreemap
[src]
fn bitand_assign(&mut self, rhs: RoaringTreemap)
[src]
impl<'a> BitOr<&'a RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl<'a, 'b> BitOr<&'a RoaringTreemap> for &'b RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl BitOr<RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the |
operator.
fn bitor(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> BitOr<RoaringTreemap> for &'a RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the |
operator.
fn bitor(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> BitOrAssign<&'a RoaringTreemap> for RoaringTreemap
[src]
fn bitor_assign(&mut self, rhs: &'a RoaringTreemap)
[src]
impl BitOrAssign<RoaringTreemap> for RoaringTreemap
[src]
fn bitor_assign(&mut self, rhs: RoaringTreemap)
[src]
impl<'a> BitXor<&'a RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl<'a, 'b> BitXor<&'a RoaringTreemap> for &'b RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl BitXor<RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> BitXor<RoaringTreemap> for &'a RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> BitXorAssign<&'a RoaringTreemap> for RoaringTreemap
[src]
fn bitxor_assign(&mut self, rhs: &'a RoaringTreemap)
[src]
impl BitXorAssign<RoaringTreemap> for RoaringTreemap
[src]
fn bitxor_assign(&mut self, rhs: RoaringTreemap)
[src]
impl Clone for RoaringTreemap
[src]
fn clone(&self) -> RoaringTreemap
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RoaringTreemap
[src]
impl Default for RoaringTreemap
[src]
fn default() -> RoaringTreemap
[src]
impl Extend<u64> for RoaringTreemap
[src]
fn extend<I: IntoIterator<Item = u64>>(&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, RoaringBitmap)> for RoaringTreemap
[src]
fn from_iter<I: IntoIterator<Item = (u32, RoaringBitmap)>>(
iterator: I
) -> RoaringTreemap
[src]
iterator: I
) -> RoaringTreemap
impl FromIterator<u64> for RoaringTreemap
[src]
fn from_iter<I: IntoIterator<Item = u64>>(iterator: I) -> RoaringTreemap
[src]
impl<'a> IntoIterator for &'a RoaringTreemap
[src]
type Item = u64
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a>ⓘ
[src]
impl IntoIterator for RoaringTreemap
[src]
type Item = u64
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIterⓘ
[src]
impl PartialEq<RoaringTreemap> for RoaringTreemap
[src]
fn eq(&self, other: &RoaringTreemap) -> bool
[src]
fn ne(&self, other: &RoaringTreemap) -> bool
[src]
impl StructuralPartialEq for RoaringTreemap
[src]
impl<'a> Sub<&'a RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl<'a, 'b> Sub<&'a RoaringTreemap> for &'b RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a RoaringTreemap) -> RoaringTreemap
[src]
impl Sub<RoaringTreemap> for RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the -
operator.
fn sub(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> Sub<RoaringTreemap> for &'a RoaringTreemap
[src]
type Output = RoaringTreemap
The resulting type after applying the -
operator.
fn sub(self, rhs: RoaringTreemap) -> RoaringTreemap
[src]
impl<'a> SubAssign<&'a RoaringTreemap> for RoaringTreemap
[src]
fn sub_assign(&mut self, rhs: &'a RoaringTreemap)
[src]
impl SubAssign<RoaringTreemap> for RoaringTreemap
[src]
fn sub_assign(&mut self, rhs: RoaringTreemap)
[src]
Auto Trait Implementations
impl RefUnwindSafe for RoaringTreemap
[src]
impl Send for RoaringTreemap
[src]
impl Sync for RoaringTreemap
[src]
impl Unpin for RoaringTreemap
[src]
impl UnwindSafe for RoaringTreemap
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,