-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.d.ts
2592 lines (2340 loc) · 105 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.
Source code at: https://github.com/SalvatorePreviti/roaring-node
Documentation at: https://salvatorepreviti.github.io/roaring-node/modules.html
Roaring Bitmap 32 documentation at: https://salvatorepreviti.github.io/roaring-node/classes/RoaringBitmap32.html
*/
import roaring = require("./");
export interface ReadonlySetLike<T> {
/**
* Despite its name, returns an iterator of the values in the set-like.
*/
keys(): Iterator<T>;
/**
* @returns a boolean indicating whether an element with the specified value exists in the set-like or not.
*/
has(value: T): boolean;
/**
* @returns the number of (unique) elements in the set-like.
*/
readonly size: number;
}
/** Gets the approximate memory allocated by the roaring bitmap library. */
export function getRoaringUsedMemory(): number;
/**
* Creates a new buffer with the given size and alignment.
* If alignment is not specified, the default alignment of 32 is used.
* The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
*
* Is the same as Buffer.alloc but is aligned.
* We need an aligned buffer to create a roaring bitmap frozen view.
*
* @param {number} size The size of the buffer to allocate.
* @param {number} [alignment=32] The alignment of the buffer to allocate.
*/
export function bufferAlignedAlloc(size: number, alignment?: number): Buffer;
/**
* Creates a new buffer not initialized with the given size and alignment.
* If alignment is not specified, the default alignment of 32 is used.
* The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
*
* Is the same as Buffer.allocUnsafe but is aligned.
* We need an aligned buffer to create a roaring bitmap frozen view.
*
* WARNING: this function is unsafe because the returned buffer may contain previously unallocated memory that may contain sensitive data.
*
* @param {number} size The size of the buffer to allocate.
* @param {number} [alignment=32] The alignment of the buffer to allocate.
*/
export function bufferAlignedAllocUnsafe(size: number, alignment?: number): Buffer;
/**
* Creates a new buffer backed by a SharedArrayBuffer with the given size and alignment.
* If alignment is not specified, the default alignment of 32 is used.
* The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
*
* Is the same as Buffer.alloc but is aligned and uses a SharedArrayBuffer as storage.
* We need an aligned buffer to create a roaring bitmap frozen view.
*
* @param {number} size The size of the buffer to allocate.
* @param {number} [alignment=32] The alignment of the buffer to allocate.
*/
export function bufferAlignedAllocShared(size: number, alignment?: number): Buffer;
/**
* Creates a new buffer backed by a SharedArrayBuffer with the given size and alignment.
* If alignment is not specified, the default alignment of 32 is used.
* The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
*
* Is the same as Buffer.allocUnsafe but is aligned and uses a SharedArrayBuffer as storage.
* We need an aligned buffer to create a roaring bitmap frozen view.
*
* WARNING: this function is unsafe because the returned buffer may contain previously unallocated memory that may contain sensitive data.
*
* @param {number} size The size of the buffer to allocate.
* @param {number} [alignment=32] The alignment of the buffer to allocate.
*/
export function bufferAlignedAllocSharedUnsafe(size: number, alignment?: number): Buffer;
/**
* Given some kind of buffer or array buffer, returns a nodejs Buffer instance that contains the same data.
* The underlying ArrayBuffer is the same.
*
* @param buffer The source
* @returns A nodejs Buffer instance that contains the same data.
*/
export function asBuffer(buffer: Buffer | ArrayBufferView | TypedArray | ArrayBuffer | SharedArrayBuffer): Buffer;
export type TypedArray =
| Uint8Array
| Uint16Array
| Uint32Array
| Uint8ClampedArray
| Int8Array
| Int16Array
| Int32Array
| Float32Array
| Float64Array;
/**
* Checks if the given buffer is memory aligned.
* If alignment is not specified, the default alignment of 32 is used.
*
* @param {TypedArray | Buffer | ArrayBuffer | SharedArrayBuffer | null | undefined} buffer The buffer to check.
* @param {number} [alignment=32] The alignment to check.
*/
export function isBufferAligned(
buffer: TypedArray | Buffer | ArrayBuffer | SharedArrayBuffer | null | undefined,
alignment?: number,
): boolean;
/**
* Ensures that the given buffer is aligned to the given alignment.
* If alignment is not specified, the default alignment of 32 is used.
* If the buffer is already aligned, it is returned.
* If the buffer is not aligned, a new aligned buffer is created with bufferAlignedAllocUnsafe or bufferAlignedAllocShared and the data is copied.
*
* @param {Buffer} buffer The buffer to align.
* @param {number} [alignment=32] The alignment to align to.
* @returns {Buffer} The aligned buffer. Can be the same as the input buffer if it was already aligned. Can be a new buffer if the input buffer was not aligned.
* @memberof RoaringBitmap32
*/
export function ensureBufferAligned(
buffer: Buffer | Uint8Array | Uint8ClampedArray | SharedArrayBuffer | Int8Array | ArrayBuffer,
alignment?: number,
): Buffer;
export enum SerializationFormat {
/**
* Stable Optimized non portable C/C++ format. Used by croaring. Can be smaller than the portable format.
*/
croaring = "croaring",
/**
* Stable Portable Java and Go format.
*/
portable = "portable",
/**
* Non portable C/C++ frozen format.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when deserialized or when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*
* When this option is used in the serialize function, the new returned buffer (if no buffer was provided) will be aligned to a 32 bytes boundary.
* This is required to create a frozen view with the method unsafeFrozenView.
*
*/
unsafe_frozen_croaring = "unsafe_frozen_croaring",
/**
* A plain binary array of 32 bits integers in little endian format. 4 bytes per value.
*/
uint32_array = "uint32_array",
}
export enum FileSerializationFormat {
/**
* Stable Optimized non portable C/C++ format. Used by croaring. Can be smaller than the portable format.
*/
croaring = "croaring",
/**
* Stable Portable Java and Go format.
*/
portable = "portable",
/**
* A plain binary array of 32 bits integers in little endian format. 4 bytes per value.
*/
uint32_array = "uint32_array",
/**
* Non portable C/C++ frozen format.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when deserialized or when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*
* When this option is used in the serialize function, the new returned buffer (if no buffer was provided) will be aligned to a 32 bytes boundary.
* This is required to create a frozen view with the method unsafeFrozenView.
*
*/
unsafe_frozen_croaring = "unsafe_frozen_croaring",
/**
* Comma separated values, all values are in decimal and in one line without spaces or other characters.
*/
comma_separated_values = "comma_separated_values",
/**
* Tab "\t" separated values, all values are in decimal and in one line without other characters.
*/
tab_separated_values = "tab_separated_values",
/**
* Newline (\n) separated values, all values are in decimal and one per line with a terminating newline.
*/
newline_separated_values = "newline_separated_values",
/**
* A JSON file in the format "[1,2,3,4...]"
*/
json_array = "json_array",
}
export type SerializationFormatType =
| SerializationFormat
| "croaring"
| "portable"
| "unsafe_frozen_croaring"
| "uint32_array"
| boolean;
export type FileSerializationFormatType =
| SerializationFormatType
| FileSerializationFormat
| "comma_separated_values"
| "tab_separated_values"
| "newline_separated_values"
| "json_array";
export type SerializationDeserializationFormatType = SerializationFormatType & DeserializationFormatType;
export type FileSerializationDeserializationFormatType = FileSerializationFormatType & FileDeserializationFormatType;
export enum DeserializationFormat {
/** Stable Optimized non portable C/C++ format. Used by croaring. Can be smaller than the portable format. */
croaring = "croaring",
/** Stable Portable Java and Go format. */
portable = "portable",
/**
* Non portable C/C++ frozen format.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*/
unsafe_frozen_croaring = "unsafe_frozen_croaring",
/**
* Portable version of the frozen view, compatible with Go and Java.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*/
unsafe_frozen_portable = "unsafe_frozen_portable",
/**
* A plain binary array of 32 bits integers in little endian format. 4 bytes per value.
*/
uint32_array = "uint32_array",
comma_separated_values = "comma_separated_values",
tab_separated_values = "tab_separated_values",
newline_separated_values = "newline_separated_values",
json_array = "json_array",
}
export type DeserializationFormatType =
| DeserializationFormat
| "croaring"
| "portable"
| "unsafe_frozen_croaring"
| "unsafe_frozen_portable"
| "uint32_array"
| "comma_separated_values"
| "tab_separated_values"
| "newline_separated_values"
| "json_array"
| boolean;
export enum FileDeserializationFormat {
/** Stable Optimized non portable C/C++ format. Used by croaring. Can be smaller than the portable format. */
croaring = "croaring",
/** Stable Portable Java and Go format. */
portable = "portable",
/**
* Non portable C/C++ frozen format.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*/
unsafe_frozen_croaring = "unsafe_frozen_croaring",
/**
* Portable version of the frozen view, compatible with Go and Java.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*/
unsafe_frozen_portable = "unsafe_frozen_portable",
/**
* A plain binary array of 32 bits integers in little endian format. 4 bytes per value.
*/
uint32_array = "uint32_array",
comma_separated_values = "comma_separated_values",
tab_separated_values = "tab_separated_values",
newline_separated_values = "newline_separated_values",
json_array = "json_array",
}
export type FileDeserializationFormatType = DeserializationFormatType | FileDeserializationFormat;
export enum FrozenViewFormat {
/**
* Non portable C/C++ frozen format.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*/
unsafe_frozen_croaring = "unsafe_frozen_croaring",
/**
* Portable version of the frozen view, compatible with Go and Java.
* Is considered unsafe and unstable because the format might change at any new version.
* Can be useful for temporary storage or for sending data over the network between similar machines.
* If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined!
* The application may crash, buffer overrun, could be a vector of attack!
*/
unsafe_frozen_portable = "unsafe_frozen_portable",
}
export type FrozenViewFormatType = FrozenViewFormat | "unsafe_frozen_croaring" | "unsafe_frozen_portable";
export interface ReadonlyRoaringBitmap32
extends Omit<ReadonlySet<number>, "forEach" | "keys" | "values" | "entries" | typeof Symbol.iterator> {
/**
* Property. Gets the number of items in the set (cardinality).
*
* @type {number}
* @memberof ReadonlyRoaringBitmap32
*/
get size(): number;
/**
* Property. True if the bitmap is empty.
*
* @type {boolean}
* @memberof ReadonlyRoaringBitmap32
*/
get isEmpty(): boolean;
/**
* Property. True if the bitmap is read-only.
* A read-only bitmap cannot be modified, every operation will throw an error.
* You can freeze a bitmap using the freeze() method.
* A bitmap cannot be unfrozen.
*
* @type {boolean}
* @memberof ReadonlyRoaringBitmap32
*/
get isFrozen(): boolean;
/**
* [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 ReadonlyRoaringBitmap32
*/
[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 ReadonlyRoaringBitmap32
*/
iterator(): RoaringBitmap32Iterator;
/**
* Gets a new iterator able to iterate all values in the set in descending 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 reverse iterator
* @memberof ReadonlyRoaringBitmap32
*/
reverseIterator(): 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 ReadonlyRoaringBitmap32
*/
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 ReadonlyRoaringBitmap32
*/
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 ReadonlyRoaringBitmap32
*/
entries(): ReturnType<Set<number>["entries"]>;
/**
* 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.
*
* WARNING: the second parameter of the callback is not the index, but the value itself, the same as the first argument.
* This is required to match the Set<number> interface.
*/
forEach<This = unknown>(
callbackfn: (this: This, value: number, index: number, set: this) => void,
thisArg?: This,
): this;
/**
* Behaves like array.some.
* The some() method tests whether at least one element in the set passes the test implemented by the provided function.
* It returns true if, in the set, it finds an element for which the provided function returns true; otherwise it returns false.
*
* WARNING: this can potentially iterate a large set of to 4 billion elements.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
*/
some(callbackfn: (value: number, index: number, set: this) => boolean, thisArg?: unknown): boolean;
/**
* Behaves like array.every.
* The every() method tests whether all elements in the set pass the test implemented by the provided function.
* It returns a Boolean value.
*
* WARNING: this can potentially iterate a large set of to 4 billion elements.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
*/
every(callbackfn: (value: number, index: number, set: this) => boolean, thisArg?: unknown): boolean;
/**
* Behaves like array.reduce.
* The reduce() method applies a function against an accumulator and each value of the set (from left-to-right) to reduce it to a single value.
*
* WARNING: this can potentially iterate a large set of to 4 billion elements.
*
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the set.
* @returns The value that results from the reduction.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce
* @memberof ReadonlyRoaringBitmap32
*/
reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, set: this) => number): number;
reduce(
callbackfn: (previousValue: number, currentValue: number, currentIndex: number, set: this) => number,
initialValue: number | undefined,
): number;
reduce<U>(
callbackfn: (previousValue: U, currentValue: number, currentIndex: number, set: this) => U,
initialValue: U,
): U;
/**
* Behaves like array.reduceRight.
* The reduceRight() method applies a function against an accumulator and each value of the set (from right-to-left) to reduce it to a single value.
* WARNING: this can potentially iterate a large set of to 4 billion elements.
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the set.
* @returns The value that results from the reduction.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight
* @memberof ReadonlyRoaringBitmap32
*/
reduceRight(
callbackfn: (previousValue: number, currentValue: number, currentIndex: number, set: this) => number,
): number;
reduceRight(
callbackfn: (previousValue: number, currentValue: number, currentIndex: number, set: this) => number,
initialValue: number | undefined,
): number;
reduceRight<U>(
callbackfn: (previousValue: U, currentValue: number, currentIndex: number, set: this) => U,
initialValue: U,
): U;
/**
* Behaves like array.find.
* The find() method returns the value of the first element in the set that satisfies the provided testing function.
* Otherwise undefined is returned.
* WARNING: this can potentially iterate a large set of to 4 billion elements.
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
* @param predicate find calls predicate once for each element of the set, in ascending order, until it finds one where predicate returns true.
* If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of predicate.
* If it is not provided, undefined is used instead.
* @returns The value of the first element in the set that satisfies the provided testing function.
* Otherwise undefined is returned.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
* @memberof ReadonlyRoaringBitmap32
*/
find(predicate: (value: number, index: number, set: this) => boolean, thisArg?: unknown): number | undefined;
/**
* Behaves like array.findIndex.
* The findIndex() method returns the index of the first element in the set that satisfies the provided testing function.
* Otherwise, it returns -1, indicating that no element passed the test.
* WARNING: this can potentially iterate a large set of to 4 billion elements.
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
* @param predicate find calls predicate once for each element of the set, in ascending order, until it finds one where predicate returns true.
* If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of predicate.
* If it is not provided, undefined is used instead.
* @returns The index of the first element in the set that satisfies the provided testing function.
* Otherwise, it returns -1, indicating that no element passed the test.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
* @memberof ReadonlyRoaringBitmap32
*/
findIndex(predicate: (value: number, index: number, set: this) => boolean, thisArg?: unknown): number;
/**
* It behaves like array.map.
* WARNING: The returned array may be very big, up to 4 billion elements.
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
* @returns An array containing the results of calling the callbackfn function on each element in the set.
* @memberof ReadonlyRoaringBitmap32
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
*/
map<U, This = unknown>(
callbackfn: (this: This, value: number, index: number, set: this) => U,
thisArg?: This,
output?: U[],
): U[];
/**
* It behaves like array.filter.
* WARNING: The returned array may be very big, up to 4 billion elements.
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
* @returns A new array containing all elements of the array that satisfy the given predicate.
* @memberof ReadonlyRoaringBitmap32
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
*/
filter(
predicate: (value: number, index: number, set: this) => boolean,
thisArg?: unknown,
output?: number[],
): number[];
/**
* It behaves like array.toSorted.
* Returns a new array that is this set sorted according to the compare function.
* If no sorting function is provided, the array is sorted according to the numeric order of the values (the same as calling this.toArray()).
*
* WARNING: The returned array may be very big, up to 4 billion elements.
* WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
*
* @param cmp A function that defines an alternative sort order. The sort method calls the compareFunction function
* once for each element in the array.
* @returns A new sorted array that contains all the elements of this set.
* @memberof ReadonlyRoaringBitmap32
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted
*/
toSorted(cmp?: (a: number, b: number) => number): number[];
/**
* It behaves like array.toReversed.
* Returns a new array that is this set sorted in reverse order.
* WARNING: The returned array may be very big, up to 4 billion elements.
* @returns An array containing the elements of this set in reverse order (descending).
*/
toReversed(): number[];
/**
* Gets the minimum value in the set.
*
* @returns {number} The minimum value in the set or 0xFFFFFFFF if empty.
* @memberof ReadonlyRoaringBitmap32
*/
minimum(): number;
/**
* Gets the maximum value in the set.
*
* @returns {number} The minimum value in the set or 0 if empty.
* @memberof ReadonlyRoaringBitmap32
*/
maximum(): number;
/**
* Checks wether the given value exists in the set.
* Is the same as this.includes(value).
*
* @param {number} value A 32 bit unsigned integer to search.
* @returns {boolean} True if the set contains the given value, false if not.
* @memberof ReadonlyRoaringBitmap32
*/
has(value: unknown): boolean;
/**
* Checks wether the given value exists in the set.
* Is the same as this.has(value).
*
* @param {number} value A 32 bit unsigned integer to search.
* @returns {boolean} True if the set contains the given value, false if not.
* @memberof ReadonlyRoaringBitmap32
*/
includes(value: unknown): boolean;
/**
* Returns the index of value in the set, index start from 0.
* If the set doesn't contain value, this function will return -1.
* The difference with rank function is that this function will return -1 when value isn't in the set, but the rank function will return a non-negative number.
*
* @param {number} value A 32 bit unsigned integer to search.
* @param {number} [fromIndex] The index to start the search at, defaults to 0. It does not have performance difference, is just for compatibility with array.indexOf.
* @returns {boolean} True if the set contains the given value, false if not.
* @memberof ReadonlyRoaringBitmap32
*/
indexOf(value: unknown, fromIndex?: number): number;
/**
* Returns the index of value in the set, index start from 0.
* If the set doesn't contain value, this function will return -1.
* The difference with rank function is that this function will return -1 when value isn't in the set, but the rank function will return a non-negative number.
* If fromIndex is not specified, is the same as this.indexOf(value).
* It behaves like array.lastIndexOf, but it doesn't have performance difference, is just for compatibility with array.lastIndexOf.
*
* @param {number} value A 32 bit unsigned integer to search.
* @param {number} [fromIndex] The index to start the search at, defaults to 0. It does not have performance difference, is just for compatibility with array.indexOf.
* @returns {boolean} True if the set contains the given value, false if not.
* @memberof ReadonlyRoaringBitmap32
*/
lastIndexOf(value: unknown, fromIndex?: number): number;
/**
* Check whether a range of values from rangeStart (included) to rangeEnd (excluded) is present
*
* @param {number|undefined} rangeStart The start index (inclusive).
* @param {number|undefined} [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 ReadonlyRoaringBitmap32
*/
hasRange(rangeStart: number | undefined, rangeEnd?: number | undefined): 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|undefined} rangeStart The start index (inclusive).
* @param {number|undefined} [rangeEnd] The end index (exclusive).
* @returns {number} The number of elements between rangeStart (included) to rangeEnd (excluded).
*/
rangeCardinality(rangeStart: number | undefined, rangeEnd?: number | undefined): number;
/**
* Checks wether this set is a subset or the same as the given set.
*
* Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set.
* @returns {boolean} True if this set is a subset of the given ReadonlyRoaringBitmap32. False if not.
* @memberof ReadonlyRoaringBitmap32
*/
isSubset(other: ReadonlyRoaringBitmap32): boolean;
/**
* Checks wether this set is a superset or the same as the given set.
*
* Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set.
* @returns {boolean} True if this set is a superset of the given ReadonlyRoaringBitmap32. False if not.
* @memberof ReadonlyRoaringBitmap32
*/
isSuperset(other: ReadonlyRoaringBitmap32): 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 ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other ReadonlyRoaringBitmap32 instance.
* @returns {boolean} True if this set is a strict subset of the given ReadonlyRoaringBitmap32. False if not.
* @memberof ReadonlyRoaringBitmap32
*/
isStrictSubset(other: ReadonlyRoaringBitmap32): boolean;
/**
* Checks wether this set is a strict superset of the given set.
*
* Returns false if the sets are the same.
*
* Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other ReadonlyRoaringBitmap32 instance.
* @returns {boolean} True if this set is a strict superset of the given ReadonlyRoaringBitmap32. False if not.
* @memberof ReadonlyRoaringBitmap32
*/
isStrictSuperset(other: ReadonlyRoaringBitmap32): boolean;
/**
* Checks wether this set is equal to another set.
*
* Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set to compare for equality.
* @returns {boolean} True if the two sets contains the same elements, false if not.
* @memberof ReadonlyRoaringBitmap32
*/
isEqual(other: ReadonlyRoaringBitmap32): 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 ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set to compare for intersection.
* @returns {boolean} True if the two set intersects, false if not.
* @memberof ReadonlyRoaringBitmap32
*/
intersects(other: ReadonlyRoaringBitmap32): boolean;
/**
* Check whether a bitmap and a closed range intersect.
*
* @param {number|undefined} rangeStart The start of the range.
* @param {number|undefined} [rangeEnd] The end of the range.
* @returns {boolean} True if the bitmap and the range intersects, false if not.
*/
intersectsWithRange(rangeStart: number | undefined, rangeEnd?: number | undefined): 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 ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof ReadonlyRoaringBitmap32
*/
andCardinality(other: ReadonlyRoaringBitmap32): number;
/**
* Computes the size of the union between two bitmaps.
*
* Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof ReadonlyRoaringBitmap32
*/
orCardinality(other: ReadonlyRoaringBitmap32): number;
/**
* Computes the size of the difference (andnot) between two bitmaps.
*
* Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof ReadonlyRoaringBitmap32
*/
andNotCardinality(other: ReadonlyRoaringBitmap32): number;
/**
* Computes the size of the symmetric difference (xor) between two bitmaps.
*
* Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other set to compare for intersection.
* @returns {number} The number of elements in common.
* @memberof ReadonlyRoaringBitmap32
*/
xorCardinality(other: ReadonlyRoaringBitmap32): 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 ReadonlyRoaringBitmap32 instance.
*
* @param {ReadonlyRoaringBitmap32} other The other ReadonlyRoaringBitmap32 to compare.
* @returns {number} The Jaccard index.
* @memberof ReadonlyRoaringBitmap32
*/
jaccardIndex(other: ReadonlyRoaringBitmap32): 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 ReadonlyRoaringBitmap32
*/
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 ReadonlyRoaringBitmap32
*/
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 billion elements.
*
* Use this function only when you know what you are doing.
*
* This function is faster than calling new Uint32Array(bitmap);
*
* See rangeUint32Array to paginate.
*
* @returns A new Uint32Array instance containing all the items in the set in order.
* @memberof ReadonlyRoaringBitmap32
*/
toUint32Array(): Uint32Array;
/**
* Creates a new Uint32Array and fills it with all the values in the bitmap up to the given length.
*
* See rangeUint32Array to paginate.
*
* @returns A new Uint32Array instance containing all the items in the set in order.
* @memberof ReadonlyRoaringBitmap32
*/
toUint32Array(maxSize: number): Uint32Array;
/**
* Copies all the values in the roaring bitmap to an Uint32Array.
*
* This function is faster than calling new Uint32Array(bitmap);
* Throws if the given array is not a valid Uint32Array or Int32Array or is not big enough.
*
* See rangeUint32Array to paginate.
*
* @param {TOutput} output The output array.
* @returns {Uint32Array} The output array. Limited to the resulting size.
* @memberof ReadonlyRoaringBitmap32
*/
toUint32Array(output: Uint32Array | Int32Array | ArrayBuffer | SharedArrayBuffer): Uint32Array;
/**
* Creates a new Uint32Array and fills it with all the values in the bitmap, asynchronously.
* The bitmap will be temporarily frozen until the operation completes.
*
* The returned array may be very big, up to 4 billion elements.
*
* Use this function only when you know what you are doing.
*
* This function is faster than calling new Uint32Array(bitmap);
*
* See rangeUint32Array to paginate.
*
* @returns A new Uint32Array instance containing all the items in the set in order.
* @memberof ReadonlyRoaringBitmap32
*/
toUint32ArrayAsync(): Promise<Uint32Array>;
/**
* Copies all the values in the roaring bitmap to an Uint32Array, asynchronously.
* The bitmap will be temporarily frozen until the operation completes.
*
* This function is faster than calling new Uint32Array(bitmap);
* Throws if the given array is not a valid Uint32Array or Int32Array or is not big enough.
*
* See rangeUint32Array to paginate.
*
* @param {TOutput} output The output array.
* @returns {Uint32Array} The output array. Limited to the resulting size.
* @memberof ReadonlyRoaringBitmap32
*/
toUint32ArrayAsync(output: Uint32Array | Int32Array | ArrayBuffer | SharedArrayBuffer): Promise<Uint32Array>;
/**
* toUint32Array array with pagination
* @returns A new Uint32Array instance containing paginated items in the set in order.
* @memberof ReadonlyRoaringBitmap32
*/
rangeUint32Array(
output: Uint32Array | Int32Array | ArrayBuffer | SharedArrayBuffer,
offset: number,
limit?: number | undefined,
): Uint32Array;
/**
* toUint32Array array with pagination
* @returns A new Uint32Array instance containing paginated items in the set in order.
* @memberof ReadonlyRoaringBitmap32
*/
rangeUint32Array(minimumValue: number, maximumValue: number): Uint32Array;
/**
* toUint32Array array with pagination
* @param {TOutput} output The output array.
* @returns {Uint32Array} The output array. Limited to the resulting size.
* @memberof ReadonlyRoaringBitmap32
*/
rangeUint32Array(
minimumValue: number,
maximumValue: number,
output: Uint32Array | Int32Array | ArrayBuffer | SharedArrayBuffer,
): Uint32Array;
/**
* toUint32Array array with pagination
* @param {TOutput} output The output array.
* @returns {Uint32Array} The output array. Limited to the resulting size.
* @memberof ReadonlyRoaringBitmap32
*/
rangeUint32Array(
minimumValue: number,
output: Uint32Array | Int32Array | ArrayBuffer | SharedArrayBuffer,
): Uint32Array;
/**
* Same as toUint32Array
* @param {TOutput} output The output array.
* @returns {Uint32Array} The output array. Limited to the resulting size.