Struct roaring::treemap::RoaringTreemap [−][src]
pub struct RoaringTreemap { /* fields omitted */ }
Expand description
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
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);
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);
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);
Creates an empty RoaringTreemap
.
Examples
use roaring::RoaringTreemap;
let mut rb = RoaringTreemap::new();
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);
Pushes value
in the treemap only if it is greater than the current maximum value.
Returns whether the value was inserted.
Examples
use roaring::RoaringTreemap;
let mut rb = RoaringTreemap::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<u64>>(), vec![1, 3, 5]);
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);
Removes a range of values. Returns the number of removed values.
Examples
use roaring::RoaringTreemap;
let mut rb = RoaringTreemap::new();
rb.insert(2);
rb.insert(3);
assert_eq!(rb.remove_range(2..4), 2);
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);
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);
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);
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);
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));
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);
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);
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);
pub fn from_sorted_iter<I: IntoIterator<Item = u64>>(
iterator: I
) -> Result<RoaringTreemap, NonSortedIntegers>
pub fn from_sorted_iter<I: IntoIterator<Item = u64>>(
iterator: I
) -> Result<RoaringTreemap, NonSortedIntegers>
Create the set from a sorted iterator. Values must be sorted and deduplicated.
The values of the iterator must be ordered and strictly greater than the greatest value in the set. If a value in the iterator doesn’t satisfy this requirement, it is not added and the append operation is stopped.
Returns Ok
with the requested RoaringTreemap
, Err
with the number of elements
we tried to append before an error occurred.
Examples
use roaring::RoaringTreemap;
let mut rb = RoaringTreemap::from_sorted_iter(0..10).unwrap();
assert!(rb.iter().eq(0..10));
pub fn append<I: IntoIterator<Item = u64>>(
&mut self,
iterator: I
) -> Result<u64, NonSortedIntegers>
pub fn append<I: IntoIterator<Item = u64>>(
&mut self,
iterator: I
) -> Result<u64, NonSortedIntegers>
Extend the set with a sorted iterator.
The values of the iterator must be ordered and strictly greater than the greatest value in the set. If a value in the iterator doesn’t satisfy this requirement, it is not added and the append operation is stopped.
Returns Ok
with the number of elements appended to the set, Err
with
the number of elements we effectively appended before an error occurred.
Examples
use roaring::RoaringTreemap;
let mut rb = RoaringTreemap::new();
rb.append(0..10);
assert!(rb.iter().eq(0..10));
👎 Deprecated since 0.6.7: Please use the BitOrAssign::bitor_assign
(|=
) ops method instead
Please use the BitOrAssign::bitor_assign
(|=
) ops method instead
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 |= 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);
👎 Deprecated since 0.6.7: Please use the BitAndAssign::bitand_assign
(&=
) ops method instead
Please use the BitAndAssign::bitand_assign
(&=
) ops method instead
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 &= 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);
👎 Deprecated since 0.6.7: Please use the SubAssign::sub_assign
(-=
) ops method instead
Please use the SubAssign::sub_assign
(-=
) ops method instead
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 -= 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);
👎 Deprecated since 0.6.7: Please use the BitXorAssign::bitxor_assign
(^=
) ops method instead
Please use the BitXorAssign::bitxor_assign
(^=
) ops method instead
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 ^= 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);
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(&bytes[..]).unwrap();
assert_eq!(rb1, rb2);
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(&bytes[..]).unwrap();
assert_eq!(rb1, rb2);
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(&bytes[..]).unwrap();
assert_eq!(rb1, rb2);
Trait Implementations
An intersection
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the &
operator.
An intersection
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the &
operator.
An intersection
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the &
operator.
An intersection
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the &
operator.
An intersection
between two sets.
An intersection
between two sets.
An union
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the |
operator.
An union
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the |
operator.
An union
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the |
operator.
An union
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the |
operator.
An union
between two sets.
An union
between two sets.
A symmetric difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
A symmetric difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
A symmetric difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
A symmetric difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the ^
operator.
A symmetric difference
between two sets.
A symmetric difference
between two sets.
Returns the “default value” for a type. Read more
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
A difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the -
operator.
A difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the -
operator.
A difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the -
operator.
A difference
between two sets.
type Output = RoaringTreemap
type Output = RoaringTreemap
The resulting type after applying the -
operator.
A difference
between two sets.
A difference
between two sets.
Auto Trait Implementations
impl RefUnwindSafe for RoaringTreemap
impl Send for RoaringTreemap
impl Sync for RoaringTreemap
impl Unpin for RoaringTreemap
impl UnwindSafe for RoaringTreemap
Blanket Implementations
Mutably borrows from an owned value. Read more