forked from SalvatorePreviti/roaring-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
1179 lines (1070 loc) · 41 KB
/
index.d.ts
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2018 Salvatore Previti
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import roaring = require('./')
/**
* Roaring bitmap that supports 32 bit unsigned integers.
*
* - See http://roaringbitmap.org/
* - See https://github.com/SalvatorePreviti/roaring-node
*
* @export
* @class RoaringBitmap32
* @implements {Iterable<number>}
* @author Salvatore Previti
*/
export class RoaringBitmap32 implements Set<number> {
// Allows: import RoaringBitmap32 from 'roaring/RoaringBitmap32'
private static readonly default: typeof RoaringBitmap32
/**
* Property: The version of the CRoaring libary as a string.
* Example: "0.4.0"
*
* @export
* @constant
* @type {string} The version of the CRoaring libary as a string. Example: "0.2.42"
*/
public static readonly CRoaringVersion: string
/**
* Property: The version of the roaring npm package as a string.
* Example: "1.2.0"
*
* @export
* @constant
* @type {string} The version of the roaring npm package as a string. Example: "0.2.42"
*/
public static readonly PackageVersion: string
/**
* Property: The version of the CRoaring libary as a string.
* Example: "0.4.0"
*
* @export
* @constant
* @type {string} The version of the CRoaring libary as a string. Example: "0.2.42"
* @memberof RoaringBitmap32
*/
public readonly CRoaringVersion: string
/**
* Property: The version of the roaring npm package as a string.
* Example: "1.2.0"
*
* @export
* @constant
* @type {string} The version of the roaring npm package as a string. Example: "0.2.42"
* @memberof RoaringBitmap32
*/
public readonly PackageVersion: string
/**
* Property. Gets the number of items in the set (cardinality).
*
* @type {number}
* @memberof RoaringBitmap32
*/
public readonly size: number
/**
* Property. True if the bitmap is empty.
*
* @type {boolean}
* @memberof RoaringBitmap32
*/
public readonly isEmpty: boolean
/**
* Creates an instance of RoaringBitmap32.
*
* Is faster to pass a Uint32Array instance instead of an array or an iterable.
*
* Is even faster if the given argument is a RoaringBitmap32 (performs a fast copy).
*
* @param {Iterable<number>} [values]
* @memberof RoaringBitmap32
*/
public constructor(values?: Iterable<number>)
/**
* Creates an instance of RoaringBitmap32 from the given Iterable.
*
* Is faster to pass a Uint32Array instance instead of an array or an iterable.
*
* Is optimized if the given argument is a RoaringBitmap32 (performs a fast copy).
*
* @static
* @param {Iterable<number>} values The values to set.
* @returns {RoaringBitmap32} A new RoaringBitmap32 instance filled with the given values.
* @memberof RoaringBitmap32
*/
public static from(values: Iterable<number>): RoaringBitmap32
/**
* Creates a new bitmap that contains all the values in the interval: [rangeStart, rangeEnd).
* Is possible to specify the step parameter to have a non contiguous range.
*
* @static
* @param {number} rangeStart The start index. Trimmed to 0.
* @param {number} rangeEnd The end index. Trimmed to 4294967297.
* @param {number} [step=1] The increment step, defaults to 1.
* @returns {RoaringBitmap32} A new RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public static fromRange(rangeStart: number, rangeEnd: number, step?: number): RoaringBitmap32
/**
*
* Creates an instance of RoaringBitmap32 from the given Iterable asynchronously in a parallel thread.
*
* If a plain array or a plain iterable is passed, a temporary Uint32Array will be created synchronously.
*
* NOTE: This method will throw a TypeError if a RoaringBitmap32 is passed as argument.
*
* Returns a Promise that resolves to a new RoaringBitmap32 instance.
*
* @static
* @param {Iterable<number>} values The values to set. Cannot be a RoaringBitmap32.
* @returns {Promise<RoaringBitmap32>} A promise that resolves to a new RoaringBitmap32 instance filled with all the given values.
* @memberof RoaringBitmap32
*/
public static fromArrayAsync(values: Iterable<number> | null | undefined): Promise<RoaringBitmap32>
/**
*
* Creates an instance of RoaringBitmap32 from the given Iterable asynchronously in a parallel thread.
*
* If a plain array or a plain iterable is passed, a temporary Uint32Array will be created synchronously.
*
* NOTE: This method will throw a TypeError if a RoaringBitmap32 is passed as argument.
*
* When deserialization is completed or failed, the given callback will be executed.
*
* @static
* @param {Iterable<number>} values The values to set. Cannot be a RoaringBitmap32.
* @param {RoaringBitmap32Callback} callback The callback to execute when the operation completes.
* @returns {void}
* @memberof RoaringBitmap32
*/
public static fromArrayAsync(values: Iterable<number> | null | undefined, callback: RoaringBitmap32Callback): void
/**
* Deserializes the bitmap from an Uint8Array or a Buffer.
*
* Returns a new RoaringBitmap32 instance.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: this field was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* @static
* @param {Uint8Array} serialized An Uint8Array or a node Buffer that contains the serialized data.
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @returns {RoaringBitmap32} A new RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public static deserialize(serialized: Uint8Array, portable: boolean): RoaringBitmap32
/**
*
* Deserializes the bitmap from an Uint8Array or a Buffer asynchrnously in a parallel thread.
*
* Returns a Promise that resolves to a new RoaringBitmap32 instance.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* @static
* @param {Uint8Array} serialized An Uint8Array or a node Buffer that contains the serialized data.
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @returns {Promise<RoaringBitmap32>} A promise that resolves to a new RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public static deserializeAsync(serialized: Uint8Array, portable: boolean): Promise<RoaringBitmap32>
/**
*
* Deserializes the bitmap from an Uint8Array or a Buffer asynchrnously in a parallel thread.
*
* When deserialization is completed or failed, the given callback will be executed.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* @static
* @param {Uint8Array} serialized An Uint8Array or a node Buffer that contains the.
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @param {RoaringBitmap32Callback} callback The callback to execute when the operation completes.
* @returns {void}
* @memberof RoaringBitmap32
*/
public static deserializeAsync(serialized: Uint8Array, portable: boolean, callback: RoaringBitmap32Callback): void
/**
*
* Deserializes many bitmaps from an array of Uint8Array or an array of Buffer asynchronously in multiple parallel threads.
*
* Returns a Promise that resolves to an array of new RoaringBitmap32 instance.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* @static
* @param {Uint8Array[]} serialized An Uint8Array or a node Buffer that contains the serialized data.
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @returns {Promise<RoaringBitmap32[]>} A promise that resolves to a new RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public static deserializeParallelAsync(
serialized: (Uint8Array | null | undefined)[],
portable: boolean
): Promise<RoaringBitmap32[]>
/**
*
* Deserializes many bitmaps from an array of Uint8Array or an array of Buffer asynchronously in a parallel thread.
*
* Deserialization in the parallel thread will be executed in sequence, if one fails, all fails.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* When deserialization is completed or failed, the given callback will be executed.
*
* @static
* @param {Uint8Array[]} serialized An array of Uint8Array or node Buffers that contains the non portable serialized data.
* @param {RoaringBitmap32ArrayCallback} callback The callback to execute when the operation completes.
* @returns {void}
* @memberof RoaringBitmap32
*/
public static deserializeParallelAsync(
serialized: (Uint8Array | null | undefined)[],
portable: boolean,
callback: RoaringBitmap32ArrayCallback
): void
/**
* Swaps the content of two RoaringBitmap32 instances.
*
* @static
* @param {RoaringBitmap32} a First RoaringBitmap32 instance to swap
* @param {RoaringBitmap32} b Second RoaringBitmap32 instance to swap
* @memberof RoaringBitmap32
*/
public static swap(a: RoaringBitmap32, b: RoaringBitmap32): void
/**
* Returns a new RoaringBitmap32 with the intersection (and) between the given two bitmaps.
*
* The provided bitmaps are not modified.
*
* @static
* @param {RoaringBitmap32} a The first RoaringBitmap32 instance to and.
* @param {RoaringBitmap32} b The second RoaringBitmap32 instance to and.
* @returns {RoaringBitmap32} A new RoaringBitmap32 that contains the intersection a AND b
* @memberof RoaringBitmap32
*/
public static and(a: RoaringBitmap32, b: RoaringBitmap32): RoaringBitmap32
/**
* Returns a new RoaringBitmap32 with the union (or) of the two given bitmaps.
*
* The provided bitmaps are not modified.
*
* @static
* @param {RoaringBitmap32} a The first RoaringBitmap32 instance to or.
* @param {RoaringBitmap32} b The second RoaringBitmap32 instance to or.
* @returns {RoaringBitmap32}
* @memberof RoaringBitmap32 A new RoaringBitmap32 that contains the union a OR b
*/
public static or(a: RoaringBitmap32, b: RoaringBitmap32): RoaringBitmap32
/**
* Returns a new RoaringBitmap32 with the symmetric union (xor) between the two given bitmaps.
*
* The provided bitmaps are not modified.
*
* @static
* @param {RoaringBitmap32} a The first RoaringBitmap32 instance to xor.
* @param {RoaringBitmap32} b The second RoaringBitmap32 instance to xor.
* @returns {RoaringBitmap32}
* @memberof RoaringBitmap32 A new RoaringBitmap32 that contains a XOR b
*/
public static xor(a: RoaringBitmap32, b: RoaringBitmap32): RoaringBitmap32
/**
* Returns a new RoaringBitmap32 with the difference (and not) between the two given bitmaps.
*
* The provided bitmaps are not modified.
*
* @static
* @param {RoaringBitmap32} a The first RoaringBitmap32 instance.
* @param {RoaringBitmap32} b The second RoaringBitmap32 instance.
* @returns {RoaringBitmap32}
* @memberof RoaringBitmap32 A new bitmap, a AND NOT b
*/
public static andNot(a: RoaringBitmap32, b: RoaringBitmap32): RoaringBitmap32
/**
* Performs a union between all the given array of RoaringBitmap32 instances.
*
* This function is faster than calling or multiple times.
*
* @static
* @param {RoaringBitmap32[]} values An array of RoaringBitmap32 instances to or together.
* @returns {RoaringBitmap32} A new RoaringBitmap32 that contains the union of all the given bitmaps.
* @memberof RoaringBitmap32
*/
public static orMany(values: RoaringBitmap32[]): RoaringBitmap32
/**
* Performs a union between all the given RoaringBitmap32 instances.
*
* This function is faster than calling or multiple times.
*
* @static
* @param {...RoaringBitmap32[]} values The RoaringBitmap32 instances to or together.
* @returns {RoaringBitmap32} A new RoaringBitmap32 that contains the union of all the given bitmaps.
* @memberof RoaringBitmap32
*/
public static orMany(...values: RoaringBitmap32[]): RoaringBitmap32
/**
* Performs a xor between all the given array of RoaringBitmap32 instances.
*
* This function is faster than calling xor multiple times.
*
* @static
* @param {RoaringBitmap32[]} values An array of RoaringBitmap32 instances to or together.
* @returns {RoaringBitmap32} A new RoaringBitmap32 that contains the xor of all the given bitmaps.
* @memberof RoaringBitmap32
*/
public static xorMany(values: RoaringBitmap32[]): RoaringBitmap32
/**
* Performs a xor between all the given RoaringBitmap32 instances.
*
* This function is faster than calling xor multiple times.
*
* @static
* @param {...RoaringBitmap32[]} values The RoaringBitmap32 instances to or together.
* @returns {RoaringBitmap32} A new RoaringBitmap32 that contains the xor of all the given bitmaps.
* @memberof RoaringBitmap32
*/
public static xorMany(...values: RoaringBitmap32[]): RoaringBitmap32
/**
* [Symbol.iterator]() Gets a new iterator able to iterate all values in the set in ascending order.
*
* WARNING: Is not allowed to change the bitmap while iterating.
* The iterator may throw exception if the bitmap is changed during the iteration.
*
* @returns {RoaringBitmap32Iterator} A new iterator
* @memberof RoaringBitmap32
*/
public [Symbol.iterator](): RoaringBitmap32Iterator
/**
* Gets a new iterator able to iterate all values in the set in ascending order.
*
* WARNING: Is not allowed to change the bitmap while iterating.
* The iterator may throw exception if the bitmap is changed during the iteration.
*
* Same as [Symbol.iterator]()
*
* @returns {RoaringBitmap32Iterator} A new iterator
* @memberof RoaringBitmap32
*/
public iterator(): RoaringBitmap32Iterator
/**
* Gets a new iterator able to iterate all values in the set in ascending order.
* This is just for compatibility with the Set<number> interface.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
* The iterator may throw exception if the bitmap is changed during the iteration.
*
* Same as [Symbol.iterator]()
*
* @returns {RoaringBitmap32Iterator} A new iterator
* @memberof RoaringBitmap32
*/
public keys(): RoaringBitmap32Iterator
/**
* Gets a new iterator able to iterate all values in the set in ascending order.
* This is just for compatibility with the Set<number> interface.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
* The iterator may throw exception if the bitmap is changed during the iteration.
*
* Same as [Symbol.iterator]()
*
* @returns {RoaringBitmap32Iterator} A new iterator
* @memberof RoaringBitmap32
*/
public values(): RoaringBitmap32Iterator
/**
* Gets a new iterator able to iterate all value pairs [value, value] in the set in ascending order.
* This is just for compatibility with the Set<number> interface.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
* The iterator may throw exception if the bitmap is changed during the iteration.
*
* Same as [Symbol.iterator]()
*
* @returns {RoaringBitmap32Iterator} A new iterator
* @memberof RoaringBitmap32
*/
public entries(): IterableIterator<[number, number]>
/**
* Executes a function for each value in the set, in ascending order.
* The callback has 3 arguments, the value, the value and this (this set). This is to match the Set<number> interface.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*/
public forEach(callbackfn: (value: number, value2: number, set: this) => void, thisArg?: any): void
/**
* Gets the minimum value in the set.
*
* @returns {number} The minimum value in the set or 0xFFFFFFFF if empty.
* @memberof RoaringBitmap32
*/
public minimum(): number
/**
* Gets the maximum value in the set.
*
* @returns {number} The minimum value in the set or 0 if empty.
* @memberof RoaringBitmap32
*/
public maximum(): number
/**
* Checks wether the given value exists in the set.
*
* @param {number} value A 32 bit unsigned integer to search.
* @returns {boolean} True if the set contains the given value, false if not.
* @memberof RoaringBitmap32
*/
public has(value: number): boolean
/**
* Check whether a range of values from rangeStart (included) to rangeEnd (excluded) is present
*
* @param {number} rangeStart The start index (inclusive).
* @param {number} rangeEnd The end index (exclusive).
* @returns {boolean} True if the bitmap contains the whole range of values from rangeStart (included) to rangeEnd (excluded), false if not.
* @memberof RoaringBitmap32
*/
public hasRange(rangeStart: number, rangeEnd: number): boolean
/**
* Gets the cardinality (number of elements) between rangeStart (included) to rangeEnd (excluded) of the bitmap.
* Returns 0 if range is invalid or if no element was found in the given range.
*
* @param {number} rangeStart The start index (inclusive).
* @param {number} rangeEnd The end index (exclusive).
* @returns {number} The number of elements between rangeStart (included) to rangeEnd (excluded).
*/
public rangeCardinality(rangeStart: number, rangeEnd: number): number
/**
* Overwrite the content of this bitmap copying it from an Iterable or another RoaringBitmap32.
*
* Is faster to pass a Uint32Array instance instead of an array or an iterable.
*
* Is even faster if a RoaringBitmap32 instance is used (it performs a simple copy).
*
* @param {Iterable<number>} values The new values or a RoaringBitmap32 instance.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public copyFrom(values: Iterable<number> | null | undefined): this
/**
* Adds a single value to the set.
*
* @param {number} value The value to add. Must be a valid 32 bit unsigned integer.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public add(value: number): this
/**
* Tries to add a single value to the set.
*
* Returns true if the value was added during this call, false if already existing or not a valid unsigned integer 32.
*
* @param {number} value The value to add. Must be a valid 32 bit unsigned integer.
* @returns {boolean} True if operation was succesfull (value added), false if not (value does not exists or is not a valid 32 bit unsigned integer).
* @memberof RoaringBitmap32
*/
public tryAdd(value: number): boolean
/**
* Adds multiple values to the set.
*
* Faster than calling add() multiple times.
*
* It is faster to insert sorted or partially sorted values.
*
* Is faster to use Uint32Array instead of arrays or iterables.
*
* Is optimized if the argument is an instance of RoaringBitmap32 (it performs an OR union).
*
* @param {Iterable<number>} values An iterable of values to insert.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public addMany(values: Iterable<number>): this
/**
* Removes a value from the set.
*
* Returns true if the value was removed during this call, false if not.
*
* @param value The unsigned 32 bit integer to remove.
* @returns True if the value was removed during this call, false if not.
* @memberof RoaringBitmap32
*/
public delete(value: number): boolean
/**
* Removes a value from the set.
*
* @param value The unsigned 32 bit integer to remove.
* @memberof RoaringBitmap32
*/
public remove(value: number): void
/**
* Removes multiple values from the set.
*
* Faster than calling remove() multiple times.
*
* Is faster to use Uint32Array instead of arrays or iterables.
*
* This function is optimized if the argument is an instance of RoaringBitmap32 (it performs an AND NOT operation).
*
* @param values An iterable of values to remove.
* @returns This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public removeMany(values: Iterable<number>): this
/**
* Negates (in place) the roaring bitmap within a specified interval: [rangeStart, rangeEnd).
*
* First element is included, last element is excluded.
* The number of negated values is rangeEnd - rangeStart.
*
* Areas outside the range are passed through unchanged.
*
* @param rangeStart The start index. Trimmed to 0.
* @param rangeEnd The end index. Trimmed to 4294967297.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public flipRange(rangeStart: number, rangeEnd: number): this
/**
* Adds all the values in the interval: [rangeStart, rangeEnd).
*
* First element is included, last element is excluded.
* The number of added values is rangeEnd - rangeStart.
*
* Areas outside the range are passed through unchanged.
*
* @param {number} rangeStart The start index. Trimmed to 0.
* @param {number} rangeEnd The end index. Trimmed to 4294967297.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public addRange(rangeStart: number, rangeEnd: number): this
/**
* Removes all the values in the interval: [rangeStart, rangeEnd).
*
* First element is included, last element is excluded.
* The number of renived values is rangeEnd - rangeStart.
*
* Areas outside the range are passed through unchanged.
* @param {number} rangeStart The start index. Trimmed to 0.
* @param {number} rangeEnd The end index. Trimmed to 4294967297.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public removeRange(rangeStart: number, rangeEnd: number): this
/**
* Removes all values from the set.
*
* It frees resources, you can use clear() to free some memory before the garbage collector disposes this instance.
*
* @memberof RoaringBitmap32
*/
public clear(): boolean
/**
* Performs an union in place ("this = this OR values"), same as addMany.
*
* Is faster to use Uint32Array instead of arrays or iterables.
*
* This function is optimized if the argument is an instance of RoaringBitmap32.
*
*
* @param {Iterable<number>} values A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public orInPlace(values: Iterable<number>): this
/**
* Performs a AND NOT operation in place ("this = this AND NOT values"), same as removeMany.
*
* Is faster to use Uint32Array instead of arrays or iterables.
*
* This function is optimized if the argument is an instance of RoaringBitmap32.
*
* @param {Iterable<number>} values A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public andNotInPlace(values: Iterable<number>): this
/**
* Performs the intersection (and) between the current bitmap and the provided bitmap,
* writing the result in the current bitmap.
*
* Is faster to use Uint32Array instead of arrays or iterables.
*
* This function is optimized if the argument is an instance of RoaringBitmap32.
*
* The provided bitmap is not modified.
*
* @param {Iterable<number>} values A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public andInPlace(values: Iterable<number>): this
/**
* Performs the symmetric union (xor) between the current bitmap and the provided bitmap,
* writing the result in the current bitmap.
*
* Is faster to use Uint32Array instead of arrays or iterables.
*
* This function is optimized if the argument is an instance of RoaringBitmap32.
*
* The provided bitmap is not modified.
*
* @param {Iterable<number>} values A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public xorInPlace(values: Iterable<number>): this
/**
* Checks wether this set is a subset or the same as the given set.
*
* Returns false also if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set.
* @returns {boolean} True if this set is a subset of the given RoaringBitmap32. False if not.
* @memberof RoaringBitmap32
*/
public isSubset(other: RoaringBitmap32): boolean
/**
* Checks wether this set is a strict subset of the given set.
*
* Returns false if the sets are the same.
*
* Returns false also if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other RoaringBitmap32 instance.
* @returns {boolean} True if this set is a strict subset of the given RoaringBitmap32. False if not.
* @memberof RoaringBitmap32
*/
public isStrictSubset(other: RoaringBitmap32): boolean
/**
* Checks wether this set is equal to another set.
*
* Returns false also if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set to compare for equality.
* @returns {boolean} True if the two sets contains the same elements, false if not.
* @memberof RoaringBitmap32
*/
public isEqual(other: RoaringBitmap32): boolean
/**
* Check whether the two bitmaps intersect.
*
* Returns true if there is at least one item in common, false if not.
*
* Returns false also if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set to compare for intersection.
* @returns {boolean} True if the two set intersects, false if not.
* @memberof RoaringBitmap32
*/
public intersects(other: RoaringBitmap32): boolean
/**
* Computes the size of the intersection between two bitmaps (the number of values in common).
*
* Returns -1 if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof RoaringBitmap32
*/
public andCardinality(other: RoaringBitmap32): number
/**
* Computes the size of the union between two bitmaps.
*
* Returns -1 if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof RoaringBitmap32
*/
public orCardinality(other: RoaringBitmap32): number
/**
* Computes the size of the difference (andnot) between two bitmaps.
*
* Returns -1 if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof RoaringBitmap32
*/
public andNotCardinality(other: RoaringBitmap32): number
/**
* Computes the size of the symmetric difference (xor) between two bitmaps.
*
* Returns -1 if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof RoaringBitmap32
*/
public xorCardinality(other: RoaringBitmap32): number
/**
* Computes the Jaccard index between two bitmaps.
* (Also known as the Tanimoto distance or the Jaccard similarity coefficient).
*
* See https://en.wikipedia.org/wiki/Jaccard_index
*
* The Jaccard index is undefined if both bitmaps are empty.
*
* Returns -1 if the given argument is not a RoaringBitmap32 instance.
*
* @param {RoaringBitmap32} other The other RoaringBitmap32 to compare.
* @returns {number} The Jaccard index.
* @memberof RoaringBitmap32
*/
public jaccardIndex(other: RoaringBitmap32): number
/**
* Remove run-length encoding even when it is more space efficient.
*
* Return whether a change was applied.
*
* @returns {boolean} True if a change was applied, false if not.
* @memberof RoaringBitmap32
*/
public removeRunCompression(): boolean
/**
* Convert array and bitmap containers to run containers when it is more efficient;
* also convert from run containers when more space efficient.
*
* Returns true if the bitmap has at least one run container.
*
* Additional savings might be possible by calling shrinkToFit().
*
* @returns {boolean} True if the bitmap has at least one run container.
* @memberof RoaringBitmap32
*/
public runOptimize(): boolean
/**
* If needed, reallocate memory to shrink the memory usage.
*
* Returns the number of bytes saved.
*
* @returns {number} The number of bytes saved.
* @memberof RoaringBitmap32
*/
public shrinkToFit(): number
/**
* Returns the number of values in the set that are smaller or equal to the given value.
*
* @param {number} maxValue The maximum value
* @returns {number} Returns the number of values in the set that are smaller or equal to the given value.
* @memberof RoaringBitmap32
*/
public rank(maxValue: number): number
/**
* If the size of the roaring bitmap is strictly greater than rank,
* then this function returns the element of given rank.
*
* Otherwise, it returns undefined.
*
* @param {number} rank The rank, an unsigned 32 bit integer.
* @returns {(number | undefined)} The element of the given rank or undefined if not found.
* @memberof RoaringBitmap32
*/
public select(rank: number): number | undefined
/**
* Creates a new Uint32Array and fills it with all the values in the bitmap.
*
* The returned array may be very big, up to 4 gigabytes.
*
* Use this function only when you know what you are doing.
*
* This function is faster than calling new Uint32Array(bitmap);
*
* @returns A new Uint32Array instance containing all the items in the set in order.
* @memberof RoaringBitmap32
*/
public toUint32Array(): Uint32Array
/**
* to array with pagination
* @returns A new Uint32Array instance containing paginated items in the set in order.
* @memberof RoaringBitmap32
*/
public rangeUint32Array(offset: number, limit: number): Uint32Array
/**
* Creates a new plain JS array and fills it with all the values in the bitmap.
*
* The returned array may be very big, use this function only when you know what you are doing.
*
* @returns {number[]} A new plain JS array that contains all the items in the set in order.
* @memberof RoaringBitmap32
*/
public toArray(): number[]
/**
* Creates a new plain JS Set<number> and fills it with all the values in the bitmap.
*
* The returned set may be very big, use this function only when you know what you are doing.
*
* @returns {Set<number>} A new plain JS array that contains all the items in the set in order.
* @memberof RoaringBitmap32
*/
public toSet(): Set<number>
/**
* Returns a plain JS array with all the values in the bitmap.
*
* Used by JSON.stringify to serialize this bitmap as an array.
*
* @returns {number[]} A new plain JS array that contains all the items in the set in order.
* @memberof RoaringBitmap32
*/
public toJSON(): number[]
/**
* How many bytes are required to serialize this bitmap.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @returns {number} How many bytes are required to serialize this bitmap.
* @memberof RoaringBitmap32
*/
public getSerializationSizeInBytes(portable: boolean): number
/**
* Serializes the bitmap into a new Buffer.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
*
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @returns {Buffer} A new node Buffer that contains the serialized bitmap.
* @memberof RoaringBitmap32
*/
public serialize(portable: boolean): Buffer
/**
* Deserializes the bitmap from an Uint8Array or a Buffer.
*
* Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
* The portable version is meant to be compatible with Java and Go versions.
*
* @param {Uint8Array} serialized An Uint8Array or a node Buffer that contains the serialized data.
* @param {boolean} portable If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
* @returns {this} This RoaringBitmap32 instance.
* @memberof RoaringBitmap32
*/
public deserialize(serialized: Uint8Array, portable: boolean): this
/**
* Returns a new RoaringBitmap32 that is a copy of this bitmap, same as new RoaringBitmap32(copy)
*
* @returns {RoaringBitmap32} A cloned RoaringBitmap32 instance
* @memberof RoaringBitmap32
*/
public clone(): RoaringBitmap32
/**
* Returns always "RoaringBitmap32".
*
* To have a standard string representation of the content as a string, call contentToString() instead.
*
* @returns {string} "Set"
* @memberof RoaringBitmap32
*/
readonly [Symbol.toStringTag]: 'Set'
/**
* Returns always "RoaringBitmap32".
*
* To have a standard string representation of the content as a string, call contentToString() instead.
*
* @returns {string} "RoaringBitmap32"
* @memberof RoaringBitmap32
*/
public toString(): string
/**
* Returns a standard string representation of the content of this RoaringBitmap32 instance. It may return a very long string.
*
* Default max length is 32000 characters, everything after maxLength is truncated (ellipsis added).
*
* @param {number} [maxLength] Approximate maximum length of the string. Default is 32000. Ellipsis will be added if the string is longer.
* @returns {string} A string in the format "[1,2,3...]"
* @memberof RoaringBitmap32
*/
public contentToString(maxLength?: number): string
/**
* Returns an object that contains statistic information about this RoaringBitmap32 instance.
*
* @returns {RoaringBitmap32Statistics} An object containing several statistics for the bitmap.
* @memberof RoaringBitmap32
*/
public statistics(): RoaringBitmap32Statistics
}
/**
* Iterator for RoaringBitmap32.
*
* WARNING: Is not allowed to change the bitmap while iterating.