-
Notifications
You must be signed in to change notification settings - Fork 484
Expand file tree
/
Copy pathBelt_MapDict.resi
More file actions
216 lines (170 loc) · 6.85 KB
/
Copy pathBelt_MapDict.resi
File metadata and controls
216 lines (170 loc) · 6.85 KB
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
/* Copyright (C) 2015-2016 Bloomberg Finance L.P.
* Copyright (C) 2017- Hongbo Zhang, Authors of ReScript
*
* SPDX-License-Identifier: MIT
*/
/***
This module separates identity from data, it is a bit more verbose but
slightly more efficient due to the fact that there is no need to pack
identity and data back after each operation.
**_Advanced usage only_**
*/
/*
## Examples
```rescript
type t<'key, 'value, 'id>
type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id>
```
*/
type t<'key, 'value, 'id>
type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id>
let empty: t<'k, 'v, 'id>
let isEmpty: t<'k, 'v, 'id> => bool
let has: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => bool
@deprecated("Use `cmp` instead")
let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int
let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int
@deprecated("Use `eq` instead")
let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool
/**
`eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is,
contain equal keys and associate them with equal data. `cmp` is the
equality predicate used to compare the data associated with the keys.
*/
let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool
@deprecated("Use `findFirstBy` instead")
let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)>
/**
`findFirstBy(m, p)` uses function `f` to find the first key value pair to
match predicate `p`.
## Examples
```rescript
module IntCmp = Belt.Id.MakeComparable({
type t = int
let cmp = Pervasives.compare
})
let s0 = Belt.Map.Dict.fromArray([(4, "4"), (1, "1"), (2, "2"), (3, "3")], ~cmp=IntCmp.cmp)
Belt.Map.Dict.findFirstBy(s0, (k, _) => k == 4) == Some((4, "4"))
```
*/
let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)>
@deprecated("Use `forEach` instead")
let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit
/**
`forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the
key as first argument, and the associated value as second argument. The
bindings are passed to `f` in increasing order with respect to the ordering
over the type of the keys.
*/
let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit
@deprecated("Use `reduce` instead")
let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b
/**
`reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN`
are the keys of all bindings in `m` (in increasing order), and `d1 ... dN`
are the associated data.
*/
let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b
@deprecated("Use `every` instead")
let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
/**
`every(m, p)` checks if all the bindings of the map satisfy the predicate
`p`. Order unspecified
*/
let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
@deprecated("Use `some` instead")
let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
/**
`some(m, p)` checks if at least one binding of the map satisfy the
predicate `p`. Order unspecified
*/
let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
let size: t<'k, 'a, 'id> => int
/** In increasing order. */
let toList: t<'k, 'a, 'id> => list<('k, 'a)>
let toArray: t<'k, 'a, 'id> => array<('k, 'a)>
let fromArray: (array<('k, 'a)>, ~cmp: cmp<'k, 'id>) => t<'k, 'a, 'id>
let keysToArray: t<'k, 'a, 'id> => array<'k>
let valuesToArray: t<'k, 'a, 'id> => array<'a>
let minKey: t<'k, _, _> => option<'k>
let maxKey: t<'k, _, _> => option<'k>
let minimum: t<'k, 'a, _> => option<('k, 'a)>
let maximum: t<'k, 'a, _> => option<('k, 'a)>
let get: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => option<'a>
let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a, ~cmp: cmp<'k, 'id>) => 'a
let getExn: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a
let getOrThrow: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a
let checkInvariantInternal: t<_> => unit
/**
`remove(m, x)` returns a map containing the same bindings as `m`, except
for `x` which is unbound in the returned map.
*/
let remove: (t<'a, 'b, 'id>, 'a, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>
let removeMany: (t<'a, 'b, 'id>, array<'a>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>
/**
`set(m, x, y)` returns a map containing the same bindings as `m`, plus a
binding of `x` to `y`. If `x` was already bound in `m`, its previous
binding disappears.
*/
let set: (t<'a, 'b, 'id>, 'a, 'b, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>
@deprecated("Use `update` instead")
let updateU: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>
let update: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>
@deprecated("Use `merge` instead")
let mergeU: (
t<'a, 'b, 'id>,
t<'a, 'c, 'id>,
('a, option<'b>, option<'c>) => option<'d>,
~cmp: cmp<'a, 'id>,
) => t<'a, 'd, 'id>
/**
`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`
and of `m2`. The presence of each such binding, and the corresponding
value, is determined with the function `f`.
*/
let merge: (
t<'a, 'b, 'id>,
t<'a, 'c, 'id>,
('a, option<'b>, option<'c>) => option<'d>,
~cmp: cmp<'a, 'id>,
) => t<'a, 'd, 'id>
let mergeMany: (t<'a, 'b, 'id>, array<('a, 'b)>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id>
@deprecated("Use `keep` instead")
let keepU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id>
/**
`keep(m, p)` returns the map with all the bindings in `m` that satisfy
predicate `p`.
*/
let keep: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id>
@deprecated("Use `partition` instead")
let partitionU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>)
/**
`partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains
all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map
with all the bindings of `s` that do not satisfy `p`.
*/
let partition: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>)
/**
`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with
all the bindings of `m` whose key is strictly less than `x`; `r` is the map
with all the bindings of `m` whose key is strictly greater than `x`; `data`
is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v`
to `x`.
*/
let split: (
t<'a, 'b, 'id>,
'a,
~cmp: cmp<'a, 'id>,
) => ((t<'a, 'b, 'id>, t<'a, 'b, 'id>), option<'b>)
@deprecated("Use `map` instead")
let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>
/**
`map(m, f)` returns a map with same domain as `m`, where the associated
value `a` of all bindings of `m` has been replaced by the result of the
application of `f` to `a`. The bindings are passed to `f` in increasing
order with respect to the ordering over the type of the keys.
*/
let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>
@deprecated("Use `mapWithKey` instead")
let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>
let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>