forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbs_internalBucketsType.js
62 lines (53 loc) · 1.1 KB
/
bs_internalBucketsType.js
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
'use strict';
var emptyOpt = undefined;
function power_2_above(_x, n) {
while(true) {
var x = _x;
if (x >= n) {
return x;
} else if ((x << 1) < x) {
return x;
} else {
_x = (x << 1);
continue ;
}
};
}
function create0(initialSize) {
var s = power_2_above(16, initialSize);
return {
size: 0,
buckets: new Array(s),
initialSize: s
};
}
function clear0(h) {
h.size = 0;
var h_buckets = h.buckets;
var len = h_buckets.length;
for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){
h_buckets[i] = emptyOpt;
}
return /* () */0;
}
function reset0(h) {
var len = h.buckets.length;
var h_initialSize = h.initialSize;
if (len === h_initialSize) {
return clear0(h);
} else {
h.size = 0;
h.buckets = new Array(h_initialSize);
return /* () */0;
}
}
function length0(h) {
return h.size;
}
exports.emptyOpt = emptyOpt;
exports.power_2_above = power_2_above;
exports.create0 = create0;
exports.clear0 = clear0;
exports.reset0 = reset0;
exports.length0 = length0;
/* No side effect */