1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! Rust wrapper for `CRoaring` (a C/C++ implementation at <https://github.com/RoaringBitmap/CRoaring>)
//!
//! The original Java version can be found at <https://github.com/RoaringBitmap/RoaringBitmap>
//! # Example
//!
//! ```rust
//! use croaring::Bitmap;
//!
//! let mut rb1 = Bitmap::new();
//! rb1.add(1);
//! rb1.add(2);
//! rb1.add(3);
//! rb1.add(4);
//! rb1.add(5);
//! rb1.add(100);
//! rb1.add(1000);
//! rb1.run_optimize();
//!
//! let mut rb2 = Bitmap::new();
//! rb2.add(3);
//! rb2.add(4);
//! rb2.add(1000);
//! rb2.run_optimize();
//!
//! let mut rb3 = Bitmap::new();
//!
//! assert_eq!(rb1.cardinality(), 7);
//! assert!(rb1.contains(3));
//!
//! rb1.and_inplace(&rb2);
//! rb3.add(5);
//! rb3.or_inplace(&rb1);
//!
//! # #[cfg(feature = "alloc")]
//! let mut rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]);
//! # #[cfg(not(feature = "alloc"))]
//! # let mut rb4 = Bitmap::new();
//!
//! rb1.and_inplace(&rb2);
//! println!("{:?}", rb1);
//!
//! rb3.add(5);
//! rb3.or_inplace(&rb1);
//!
//! println!("{:?}", rb1);
//!
//! rb3.add(5);
//! rb3.or_inplace(&rb1);
//!
//! # #[cfg(feature = "alloc")]
//! println!("{:?}", rb3.to_vec());
//! println!("{:?}", rb3);
//! println!("{:?}", rb4);
//!
//! # #[cfg(feature = "alloc")]
//! # {
//! rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]);
//! # }
//!
//! println!("{:?}", rb4);
//! ```
use PhantomData;
/// A compressed bitmap
// Must be repr(transparent) and match BitmapView, to allow safe transmute between
// &BitmapView and &Bitmap
unsafe
unsafe
/// A frozen view of a bitmap, backed by a byte slice
///
/// All read-only methods for [`Bitmap`] are also usable on a [`BitmapView`]
unsafe
unsafe
/// Detailed statistics on the composition of a bitmap
///
/// See [`Bitmap::statistics`] for more information
pub use ;
pub use LazyBitmap;
pub use ;