forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbelt_internalAVLtree.mli
215 lines (165 loc) · 5.58 KB
/
belt_internalAVLtree.mli
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
(* Copyright (C) 2018 Authors of ReScript
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
type ('key, 'a) t = ('key, 'a) node option
and ('k, 'v) node = {
mutable key : 'k; [@bs.as "k"]
mutable value : 'v; [@bs.as "v"]
mutable height : int; [@bs.as "h"]
mutable left : ('k,'v) t; [@bs.as "l"]
mutable right : ('k,'v) t [@bs.as "r"]
}
type ('k, 'id) cmp = ('k, 'id) Belt_Id.cmp
val copy : ('k, 'v) t -> ('k, 'v) t
val create :
('a,'b) t -> 'a -> 'b -> ('a,'b) t -> ('a,'b) t
val bal :
('a,'b) t -> 'a -> 'b -> ('a,'b) t -> ('a,'b) t
val singleton : 'a -> 'b -> ('a,'b) t
val updateValue : ('k, 'v) node -> 'v -> ('k,'v) node
val minKey: ('a, 'b) t -> 'a option
val minKeyUndefined: ('a, 'b) t -> 'a Js.undefined
val maxKey : ('a, 'b) t -> 'a option
val maxKeyUndefined : ('a, 'b) t -> 'a Js.undefined
val minimum : ('a, 'b) t -> ('a * 'b) option
val minUndefined : ('a,'b) t -> ('a * 'b) Js.undefined
val maximum : ('a,'b) t -> ('a * 'b) option
val maxUndefined : ('a,'b) t -> ('a * 'b) Js.undefined
val removeMinAuxWithRef : ('a, 'b) node -> 'a ref -> 'b ref -> ('a,'b) t
val isEmpty : _ t -> bool
val stackAllLeft :
('a,'b) t -> ('a, 'b) node list -> ('a, 'b) node list
val findFirstByU : ('a, 'b) t -> ('a -> 'b -> bool [@bs]) -> ('a * 'b) option
val findFirstBy : ('a, 'b) t -> ('a -> 'b -> bool ) -> ('a * 'b) option
val forEachU: ('a,'b) t -> ('a -> 'b -> unit [@bs]) -> unit
val forEach: ('a,'b) t -> ('a -> 'b -> unit) -> unit
val mapU: ('c, 'a) t -> ('a -> 'b [@bs]) -> ('c, 'b) t
val map: ('c, 'a) t -> ('a -> 'b) -> ('c, 'b) t
val mapWithKeyU: ('a,'b) t -> ('a -> 'b -> 'c [@bs]) -> ('a, 'c) t
val mapWithKey: ('a,'b) t -> ('a -> 'b -> 'c) -> ('a, 'c) t
val reduceU: ('a,'b) t -> 'c -> ( 'c -> 'a -> 'b -> 'c [@bs]) -> 'c
val reduce: ('a,'b) t -> 'c -> ( 'c -> 'a -> 'b -> 'c ) -> 'c
val everyU: ('a,'b) t -> ('a -> 'b -> bool [@bs]) -> bool
val every: ('a,'b) t -> ('a -> 'b -> bool) -> bool
val someU: ('a,'b) t -> ('a -> 'b -> bool [@bs]) -> bool
val some: ('a,'b) t -> ('a -> 'b -> bool) -> bool
val join: ('a,'b) t -> 'a -> 'b -> ('a,'b) t -> ('a, 'b) t
val concat: ('a,'b) t -> ('a,'b) t -> ('a,'b) t
val concatOrJoin:
('a,'b) t -> 'a -> 'b option -> ('a,'b) t -> ('a, 'b) t
val keepSharedU:
('a,'b) t ->
('a -> 'b -> bool [@bs]) ->
('a,'b) t
val keepShared:
('a,'b) t ->
('a -> 'b -> bool) ->
('a,'b) t
val keepMapU:
('a, 'b) t ->
('a -> 'b -> 'c option [@bs]) ->
('a, 'c) t
val keepMap:
('a, 'b) t ->
('a -> 'b -> 'c option ) ->
('a, 'c) t
(* seems no sharing, could be shared with mutation *)
val partitionSharedU:
('a,'b) t ->
('a -> 'b -> bool [@bs]) ->
('a,'b) t * ('a,'b) t
val partitionShared:
('a,'b) t ->
('a -> 'b -> bool ) ->
('a,'b) t * ('a,'b) t
val lengthNode : ('a, 'b) node -> int
val size : ('a,'b) t -> int
val toList : ('a,'b) t -> ('a * 'b) list
val checkInvariantInternal : ('a,'b) t -> unit
(**
**raise** when invariant is not held
*)
val fillArray : ('a,'b) node -> int -> ('a * 'b) array -> int
val toArray : ('a, 'b) t -> ('a * 'b) array
val keysToArray : ('a, 'b) t -> 'a array
val valuesToArray : ('a, 'b) t -> 'b array
val fromSortedArrayAux : ('a * 'b) array -> int -> int -> ('a, 'b) t
val fromSortedArrayRevAux : ('a * 'b) array -> int -> int -> ('a, 'b) t
val fromSortedArrayUnsafe : ('a * 'b) array -> ('a, 'b) t
val cmpU:
('a, 'b) t -> ('a, 'c) t ->
kcmp:('a,_) cmp ->
vcmp :('b -> 'c -> int [@bs]) ->
int
val cmp:
('a, 'b) t -> ('a, 'c) t ->
kcmp:('a,_) cmp ->
vcmp :('b -> 'c -> int) ->
int
val eqU:
('a, 'b) t -> ('a, 'c) t ->
kcmp:('a,_) cmp ->
veq:('b -> 'c -> bool [@bs]) ->
bool
val eq:
('a, 'b) t -> ('a, 'c) t ->
kcmp:('a,_) cmp ->
veq:('b -> 'c -> bool) ->
bool
val get:
('a, 'b) t ->
'a ->
cmp:('a,_) cmp ->
'b option
val getUndefined:
('a, 'b) t ->
'a ->
cmp:('a,_) cmp ->
'b Js.undefined
val getWithDefault:
('a, 'b) t ->
'a ->
'b ->
cmp:('a,_) cmp ->
'b
val getExn:
('a, 'b) t ->
'a ->
cmp:('a,_) cmp ->
'b
val has:
('a, 'b) t ->
'a ->
cmp:('a,_) cmp ->
bool
val fromArray : ('a * 'b) array -> cmp:('a,'id) cmp -> ('a, 'b) t
val updateMutate :
('a, 'b) t -> 'a -> 'b ->
cmp:('a,'id) cmp ->
('a, 'b) t
val balMutate :
('a, 'b) node -> ('a, 'b) node
val removeMinAuxWithRootMutate :
('a, 'b) node ->
('a, 'b) node ->
('a, 'b) t