1
1
import croaring
2
2
3
- /**
4
- * This class contains different values about a given RoaringBitmap
5
- * /
3
+ ///
4
+ /// This class contains different values about a given RoaringBitmap
5
+ // /
6
6
public typealias RoaringStatistics = roaring_statistics_t
7
7
8
- /**
9
- * Swift wrapper for CRoaring (a C/C++ implementation at https://github.com/RoaringBitmap/CRoaring)
10
- * /
8
+ ///
9
+ /// Swift wrapper for CRoaring (a C/C++ implementation at https://github.com/RoaringBitmap/CRoaring)
10
+ // /
11
11
public class RoaringBitmap : Sequence , Equatable , CustomStringConvertible ,
12
12
Hashable , ExpressibleByArrayLiteral {
13
13
var ptr : UnsafeMutablePointer < roaring_bitmap_t >
@@ -72,7 +72,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
72
72
/// caller is
73
73
/// responsible for memory management.
74
74
///
75
- ///
76
75
public func intersection( _ x: RoaringBitmap ) -> RoaringBitmap {
77
76
return RoaringBitmap ( ptr: croaring. roaring_bitmap_and ( self . ptr, x. ptr) )
78
77
}
@@ -81,7 +80,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
81
80
/// caller is
82
81
/// responsible for memory management.
83
82
///
84
- ///
85
83
public static func & ( left: RoaringBitmap , right: RoaringBitmap ) -> RoaringBitmap {
86
84
return left. intersection ( right)
87
85
}
@@ -102,15 +100,13 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
102
100
///
103
101
/// Computes the size of the intersection between two bitmaps.
104
102
///
105
- ///
106
103
public func intersectionCount( _ x: RoaringBitmap ) -> UInt64 {
107
104
return croaring. roaring_bitmap_and_cardinality ( self . ptr, x. ptr)
108
105
}
109
106
110
107
///
111
108
/// Check whether two bitmaps intersect.
112
109
///
113
- ///
114
110
public func intersect( _ x: RoaringBitmap ) -> Bool {
115
111
return croaring. roaring_bitmap_intersect ( self . ptr, x. ptr)
116
112
}
@@ -122,23 +118,20 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
122
118
///
123
119
/// The Jaccard index is undefined if both bitmaps are empty.
124
120
///
125
- ///
126
121
public func jaccardIndex( _ x: RoaringBitmap ) -> Double {
127
122
return croaring. roaring_bitmap_jaccard_index ( self . ptr, x. ptr)
128
123
}
129
124
130
125
///
131
126
/// Computes the size of the union between two bitmaps.
132
127
///
133
- ///
134
128
public func unionCount( _ x: RoaringBitmap ) -> UInt64 {
135
129
return croaring. roaring_bitmap_or_cardinality ( self . ptr, x. ptr)
136
130
}
137
131
138
132
///
139
133
/// Computes the size of the difference (andnot) between two bitmaps.
140
134
///
141
- ///
142
135
public func subtractingCount( _ x: RoaringBitmap ) -> UInt64 {
143
136
return croaring. roaring_bitmap_andnot_cardinality ( self . ptr, x. ptr)
144
137
}
@@ -153,7 +146,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
153
146
///
154
147
/// Computes the size of the symmetric difference (andnot) between two bitmaps.
155
148
///
156
- ///
157
149
public func symmetricDifferenceCount( _ x: RoaringBitmap ) -> UInt64 {
158
150
return croaring. roaring_bitmap_xor_cardinality ( self . ptr, x. ptr)
159
151
}
@@ -180,18 +172,16 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
180
172
croaring. roaring_bitmap_or_inplace ( self . ptr, x. ptr)
181
173
}
182
174
///
183
- /// Inplace version of roaring_bitmap_or, modifies x1.
175
+ /// Inplace version of ` roaring_bitmap_or, modifies` x1.
184
176
///
185
177
public static func |= ( left: RoaringBitmap , right: RoaringBitmap ) {
186
178
left. formUnion ( right)
187
179
}
188
180
189
181
///
190
- /// Compute the union of 'number' bitmaps. See also roaring_bitmap_or_many_heap.
191
- /// Caller is responsible for freeing the
192
- /// result.
182
+ /// Compute the union of 'number' bitmaps. See also `roaring_bitmap_or_many_heap`.
183
+ /// Caller is responsible for freeing the result.
193
184
///
194
-
195
185
public func unionMany( _ xs: [ RoaringBitmap ] ) -> RoaringBitmap {
196
186
let ptr = UnsafeMutablePointer< Optional< UnsafePointer< roaring_bitmap_t>>> . allocate( capacity: xs. count + 1 )
197
187
ptr [ 0 ] = UnsafePointer < roaring_bitmap_t > ( self . ptr)
@@ -202,11 +192,10 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
202
192
}
203
193
///
204
194
/// Compute the union of 'number' bitmaps using a heap. This can
205
- /// sometimes be faster than roaring_bitmap_or_many which uses
195
+ /// sometimes be faster than ` roaring_bitmap_or_many` which uses
206
196
/// a naive algorithm. Caller is responsible for freeing the
207
197
/// result.
208
198
///
209
- ///
210
199
public func unionManyHeap( _ xs: [ RoaringBitmap ] ) -> RoaringBitmap {
211
200
let ptr = UnsafeMutablePointer< Optional< UnsafePointer< roaring_bitmap_t>>> . allocate( capacity: xs. count + 1 )
212
201
ptr [ 0 ] = UnsafePointer < roaring_bitmap_t > ( self . ptr)
@@ -234,14 +223,12 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
234
223
///
235
224
/// Inplace version of roaring_bitmap_xor, modifies x1. x1 != x2.
236
225
///
237
- ///
238
226
public func formSymmetricDifference( _ x: RoaringBitmap ) {
239
227
croaring. roaring_bitmap_xor_inplace ( self . ptr, x. ptr)
240
228
}
241
229
///
242
230
/// Inplace version of roaring_bitmap_xor, modifies x1. x1 != x2.
243
231
///
244
- ///
245
232
public static func ^= ( left: RoaringBitmap , right: RoaringBitmap ) {
246
233
left. formSymmetricDifference ( right)
247
234
}
@@ -251,7 +238,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
251
238
/// Caller is responsible for freeing the
252
239
/// result.
253
240
///
254
- ///
255
241
public func symmetricDifferenceMany( _ xs: [ RoaringBitmap ] ) -> RoaringBitmap {
256
242
let ptr = UnsafeMutablePointer< Optional< UnsafePointer< roaring_bitmap_t>>> . allocate( capacity: xs. count + 1 )
257
243
ptr [ 0 ] = UnsafePointer < roaring_bitmap_t > ( self . ptr)
@@ -279,14 +265,12 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
279
265
///
280
266
/// Inplace version of roaring_bitmap_andnot, modifies x1. x1 != x2.
281
267
///
282
- ///
283
268
public func subtract( _ x: RoaringBitmap ) {
284
269
croaring. roaring_bitmap_andnot_inplace ( self . ptr, x. ptr)
285
270
}
286
271
///
287
272
/// Inplace version of roaring_bitmap_andnot, modifies x1. x1 != x2.
288
273
///
289
- ///
290
274
public static func -= ( left: RoaringBitmap , right: RoaringBitmap ) {
291
275
left. subtract ( right)
292
276
}
@@ -365,7 +349,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
365
349
/// to call roaring_bitmap_repair_after_lazy after executing "lazy" computations.
366
350
/// It is safe to repeatedly call roaring_bitmap_lazy_xor_inplace on the result.
367
351
///
368
- ///
369
352
public func lazySymmetricDifference( _ x: RoaringBitmap ) -> RoaringBitmap {
370
353
return RoaringBitmap ( ptr: croaring. roaring_bitmap_lazy_xor ( self . ptr, x. ptr) )
371
354
}
@@ -374,7 +357,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
374
357
/// (For expert users who seek high performance.)
375
358
/// Inplace version of roaring_bitmap_lazy_xor, modifies x1. x1 != x2
376
359
///
377
- ///
378
360
public func formLazySymmetricDifference( _ x: RoaringBitmap ) {
379
361
croaring. roaring_bitmap_lazy_xor_inplace ( self . ptr, x. ptr)
380
362
}
@@ -407,7 +389,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
407
389
/// Copies a bitmap. This does memory allocation. The caller is responsible for
408
390
/// memory management.
409
391
///
410
- ///
411
392
public func copy( ) -> RoaringBitmap {
412
393
return RoaringBitmap ( ptr: croaring. roaring_bitmap_copy ( self . ptr) )
413
394
}
@@ -428,7 +409,6 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
428
409
///
429
410
/// Add value x
430
411
///
431
- ///
432
412
public func add( _ value: UInt32 ) {
433
413
croaring. roaring_bitmap_add ( self . ptr, value)
434
414
}
@@ -625,6 +605,7 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
625
605
return croaring. roaring_bitmap_serialize ( self . ptr, & buffer)
626
606
}
627
607
608
+ ///
628
609
/// use with roaring_bitmap_serialize
629
610
/// see roaring_bitmap_portable_deserialize if you want a format that's
630
611
/// compatible with Java and Go implementations
@@ -734,7 +715,7 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
734
715
}
735
716
736
717
///
737
- /// (For advanced users.)
718
+ /// (For advanced users.)
738
719
/// Collect statistics about the bitmap, see RoaringStatistics.swift for
739
720
/// a description of RoaringStatistics
740
721
///
@@ -772,7 +753,9 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
772
753
}
773
754
}
774
755
775
- /* returns a string representation of the bitset */
756
+ ///
757
+ /// returns a string representation of the bitset
758
+ ///
776
759
public var description : String {
777
760
var ret = prefix ( 100 ) . map { $0. description } . joined ( separator: " , " )
778
761
if self . count >= 100 {
@@ -781,8 +764,10 @@ public class RoaringBitmap: Sequence, Equatable, CustomStringConvertible,
781
764
return " { \( ret) } "
782
765
}
783
766
784
- /* hash value for the bitset, this is expensive and should be buffered
785
- for performance */
767
+ ///
768
+ /// hash value for the bitset, this is expensive and should be buffered
769
+ /// for performance
770
+ ///
786
771
public func hash( into hasher: inout Hasher ) {
787
772
let b : UInt32 = 31
788
773
var hash : UInt32 = 0
0 commit comments