@@ -16,7 +16,25 @@ const SERIAL_COOKIE_NO_RUNCONTAINER: u32 = 12346;
16
16
const SERIAL_COOKIE : u16 = 12347 ;
17
17
18
18
impl RoaringBitmap {
19
- pub fn union_with_serialized ( & mut self , mut reader : impl Read ) -> io:: Result < ( ) > {
19
+ /// Returns the union between a roaring bitmap and a serialized roaring bitmap.
20
+ ///
21
+ /// Example
22
+ /// =======
23
+ ///
24
+ /// ```
25
+ /// use roaring::RoaringBitmap;
26
+ ///
27
+ /// let mut a = RoaringBitmap::from_sorted_iter(0..3000).unwrap();
28
+ /// let b = RoaringBitmap::from_sorted_iter(2000..6000).unwrap();
29
+ /// let union = &a | &b;
30
+ ///
31
+ /// let mut b_ser = Vec::new();
32
+ /// b.serialize_into(&mut b_ser).unwrap();
33
+ /// a.union_with_serialized_unchecked(&*b_ser).unwrap();
34
+ ///
35
+ /// assert_eq!(a, union);
36
+ /// ```
37
+ pub fn union_with_serialized_unchecked ( & mut self , mut reader : impl Read ) -> io:: Result < ( ) > {
20
38
let ( size, has_offsets) = {
21
39
let cookie = reader. read_u32 :: < LittleEndian > ( ) ?;
22
40
if cookie == SERIAL_COOKIE_NO_RUNCONTAINER {
@@ -122,7 +140,7 @@ mod test {
122
140
123
141
let mut b_ser = Vec :: new( ) ;
124
142
b. serialize_into( & mut b_ser) . unwrap( ) ;
125
- a. union_with_serialized ( & * b_ser) . unwrap( ) ;
143
+ a. union_with_serialized_unchecked ( & * b_ser) . unwrap( ) ;
126
144
127
145
prop_assert_eq!( a, union ) ;
128
146
}
@@ -165,7 +183,7 @@ mod test {
165
183
166
184
let mut b_ser = Vec :: new ( ) ;
167
185
b. serialize_into ( & mut b_ser) . unwrap ( ) ;
168
- a. union_with_serialized ( & * b_ser) . unwrap ( ) ;
186
+ a. union_with_serialized_unchecked ( & * b_ser) . unwrap ( ) ;
169
187
170
188
assert_eq ! ( a, union , "When testing: {a:?} | {b:?}" ) ;
171
189
}
0 commit comments