@fable-org/fable-library-ts 1.10.0 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Array.ts +1378 -1378
- package/Async.ts +13 -14
- package/BigInt.ts +48 -22
- package/CHANGELOG.md +18 -1
- package/Choice.ts +301 -301
- package/Date.ts +47 -41
- package/Decimal.ts +29 -1
- package/FSharp.Collections.ts +34 -34
- package/FSharp.Core.CompilerServices.ts +37 -37
- package/FSharp.Core.ts +184 -184
- package/Global.ts +37 -37
- package/List.ts +1417 -1417
- package/Map.ts +1552 -1552
- package/MapUtil.ts +3 -0
- package/MutableMap.ts +345 -345
- package/MutableSet.ts +249 -249
- package/Native.ts +11 -11
- package/Numeric.ts +8 -3
- package/Random.ts +181 -181
- package/Range.ts +56 -56
- package/Result.ts +196 -196
- package/Seq.ts +1525 -1525
- package/Seq2.ts +129 -129
- package/Set.ts +1955 -1955
- package/String.ts +81 -10
- package/System.Collections.Generic.ts +380 -380
- package/System.Text.ts +203 -203
- package/Types.ts +1 -1
- package/package.json +1 -1
package/MutableMap.ts
CHANGED
|
@@ -1,345 +1,345 @@
|
|
|
1
|
-
import { IEqualityComparer, IDisposable, disposeSafe, defaultOf, IMap, equals, toIterator, IEnumerator, getEnumerator } from "./Util.js";
|
|
2
|
-
import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
|
|
3
|
-
import { value as value_1, Option } from "./Option.js";
|
|
4
|
-
import { int32 } from "./Int32.js";
|
|
5
|
-
import { setItem } from "./Array.js";
|
|
6
|
-
import { FSharpRef } from "./Types.js";
|
|
7
|
-
import { class_type, TypeInfo } from "./Reflection.js";
|
|
8
|
-
import { getItemFromDict, tryGetValue } from "./MapUtil.js";
|
|
9
|
-
import { format } from "./String.js";
|
|
10
|
-
|
|
11
|
-
export class Dictionary<Key, Value> implements IMap<Key, Value>, Iterable<[Key, Value]>, Iterable<[Key, Value]> {
|
|
12
|
-
readonly comparer: IEqualityComparer<Key>;
|
|
13
|
-
readonly hashMap: IMap<int32, [Key, Value][]>;
|
|
14
|
-
"init@9": int32;
|
|
15
|
-
constructor(pairs: Iterable<[Key, Value]>, comparer: IEqualityComparer<Key>) {
|
|
16
|
-
const this$: FSharpRef<Dictionary<Key, Value>> = new FSharpRef<Dictionary<Key, Value>>(defaultOf());
|
|
17
|
-
this.comparer = comparer;
|
|
18
|
-
this$.contents = this;
|
|
19
|
-
this.hashMap = (new Map<int32, [Key, Value][]>([]));
|
|
20
|
-
this["init@9"] = 1;
|
|
21
|
-
const enumerator: IEnumerator<[Key, Value]> = getEnumerator(pairs);
|
|
22
|
-
try {
|
|
23
|
-
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
24
|
-
const pair: [Key, Value] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
25
|
-
Dictionary__Add_5BDDA1<Key, Value>(this$.contents, pair[0], pair[1]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
disposeSafe(enumerator as IDisposable);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
get [Symbol.toStringTag](): string {
|
|
33
|
-
return "Dictionary";
|
|
34
|
-
}
|
|
35
|
-
toJSON(): any {
|
|
36
|
-
const this$: Dictionary<Key, Value> = this;
|
|
37
|
-
return Array.from(this$);
|
|
38
|
-
}
|
|
39
|
-
"System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any> {
|
|
40
|
-
const this$: Dictionary<Key, Value> = this;
|
|
41
|
-
return getEnumerator(this$);
|
|
42
|
-
}
|
|
43
|
-
GetEnumerator(): IEnumerator<[Key, Value]> {
|
|
44
|
-
const this$: Dictionary<Key, Value> = this;
|
|
45
|
-
return getEnumerator(concat<[Key, Value][], [Key, Value]>(this$.hashMap.values()));
|
|
46
|
-
}
|
|
47
|
-
[Symbol.iterator](): Iterator<[Key, Value]> {
|
|
48
|
-
return toIterator(getEnumerator(this));
|
|
49
|
-
}
|
|
50
|
-
"System.Collections.Generic.ICollection`1.Add2B595"(item: [Key, Value]): void {
|
|
51
|
-
const this$: Dictionary<Key, Value> = this;
|
|
52
|
-
Dictionary__Add_5BDDA1<Key, Value>(this$, item[0], item[1]);
|
|
53
|
-
}
|
|
54
|
-
"System.Collections.Generic.ICollection`1.Clear"(): void {
|
|
55
|
-
const this$: Dictionary<Key, Value> = this;
|
|
56
|
-
Dictionary__Clear<Key, Value>(this$);
|
|
57
|
-
}
|
|
58
|
-
"System.Collections.Generic.ICollection`1.Contains2B595"(item: [Key, Value]): boolean {
|
|
59
|
-
const this$: Dictionary<Key, Value> = this;
|
|
60
|
-
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, item[0]);
|
|
61
|
-
let matchResult: int32, p_1: [Key, Value];
|
|
62
|
-
if (matchValue != null) {
|
|
63
|
-
if (equals(value_1(matchValue)[1], item[1])) {
|
|
64
|
-
matchResult = 0;
|
|
65
|
-
p_1 = value_1(matchValue);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
matchResult = 1;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
matchResult = 1;
|
|
73
|
-
}
|
|
74
|
-
switch (matchResult) {
|
|
75
|
-
case 0:
|
|
76
|
-
return true;
|
|
77
|
-
default:
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: [Key, Value][], arrayIndex: int32): void {
|
|
82
|
-
const this$: Dictionary<Key, Value> = this;
|
|
83
|
-
iterateIndexed<[Key, Value]>((i: int32, e: [Key, Value]): void => {
|
|
84
|
-
setItem(array, arrayIndex + i, e);
|
|
85
|
-
}, this$);
|
|
86
|
-
}
|
|
87
|
-
"System.Collections.Generic.ICollection`1.get_Count"(): int32 {
|
|
88
|
-
const this$: Dictionary<Key, Value> = this;
|
|
89
|
-
return Dictionary__get_Count<Key, Value>(this$) | 0;
|
|
90
|
-
}
|
|
91
|
-
"System.Collections.Generic.ICollection`1.get_IsReadOnly"(): boolean {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
"System.Collections.Generic.ICollection`1.Remove2B595"(item: [Key, Value]): boolean {
|
|
95
|
-
const this$: Dictionary<Key, Value> = this;
|
|
96
|
-
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, item[0]);
|
|
97
|
-
if (matchValue != null) {
|
|
98
|
-
if (equals(value_1(matchValue)[1], item[1])) {
|
|
99
|
-
Dictionary__Remove_2B595<Key, Value>(this$, item[0]);
|
|
100
|
-
}
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
"System.Collections.Generic.IDictionary`2.Add5BDDA1"(key: Key, value: Value): void {
|
|
108
|
-
const this$: Dictionary<Key, Value> = this;
|
|
109
|
-
Dictionary__Add_5BDDA1<Key, Value>(this$, key, value);
|
|
110
|
-
}
|
|
111
|
-
"System.Collections.Generic.IDictionary`2.ContainsKey2B595"(key: Key): boolean {
|
|
112
|
-
const this$: Dictionary<Key, Value> = this;
|
|
113
|
-
return Dictionary__ContainsKey_2B595<Key, Value>(this$, key);
|
|
114
|
-
}
|
|
115
|
-
"System.Collections.Generic.IDictionary`2.get_Item2B595"(key: Key): Value {
|
|
116
|
-
const this$: Dictionary<Key, Value> = this;
|
|
117
|
-
return Dictionary__get_Item_2B595<Key, Value>(this$, key);
|
|
118
|
-
}
|
|
119
|
-
"System.Collections.Generic.IDictionary`2.set_Item5BDDA1"(key: Key, v: Value): void {
|
|
120
|
-
const this$: Dictionary<Key, Value> = this;
|
|
121
|
-
Dictionary__set_Item_5BDDA1<Key, Value>(this$, key, v);
|
|
122
|
-
}
|
|
123
|
-
"System.Collections.Generic.IDictionary`2.get_Keys"(): Iterable<Key> {
|
|
124
|
-
const this$: Dictionary<Key, Value> = this;
|
|
125
|
-
return toArray<Key>(delay<Key>((): Iterable<Key> => map<[Key, Value], Key>((pair: [Key, Value]): Key => pair[0], this$)));
|
|
126
|
-
}
|
|
127
|
-
"System.Collections.Generic.IDictionary`2.Remove2B595"(key: Key): boolean {
|
|
128
|
-
const this$: Dictionary<Key, Value> = this;
|
|
129
|
-
return Dictionary__Remove_2B595<Key, Value>(this$, key);
|
|
130
|
-
}
|
|
131
|
-
"System.Collections.Generic.IDictionary`2.TryGetValue6DC89625"(key: Key, value: FSharpRef<Value>): boolean {
|
|
132
|
-
const this$: Dictionary<Key, Value> = this;
|
|
133
|
-
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, key);
|
|
134
|
-
if (matchValue != null) {
|
|
135
|
-
const pair: [Key, Value] = value_1(matchValue);
|
|
136
|
-
value.contents = pair[1];
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
"System.Collections.Generic.IDictionary`2.get_Values"(): Iterable<Value> {
|
|
144
|
-
const this$: Dictionary<Key, Value> = this;
|
|
145
|
-
return toArray<Value>(delay<Value>((): Iterable<Value> => map<[Key, Value], Value>((pair: [Key, Value]): Value => pair[1], this$)));
|
|
146
|
-
}
|
|
147
|
-
get size(): int32 {
|
|
148
|
-
const this$: Dictionary<Key, Value> = this;
|
|
149
|
-
return Dictionary__get_Count<Key, Value>(this$) | 0;
|
|
150
|
-
}
|
|
151
|
-
clear(): void {
|
|
152
|
-
const this$: Dictionary<Key, Value> = this;
|
|
153
|
-
Dictionary__Clear<Key, Value>(this$);
|
|
154
|
-
}
|
|
155
|
-
delete(k: Key): boolean {
|
|
156
|
-
const this$: Dictionary<Key, Value> = this;
|
|
157
|
-
return Dictionary__Remove_2B595<Key, Value>(this$, k);
|
|
158
|
-
}
|
|
159
|
-
entries(): Iterable<[Key, Value]> {
|
|
160
|
-
const this$: Dictionary<Key, Value> = this;
|
|
161
|
-
return map<[Key, Value], [Key, Value]>((p: [Key, Value]): [Key, Value] => ([p[0], p[1]] as [Key, Value]), this$);
|
|
162
|
-
}
|
|
163
|
-
get(k: Key): Value {
|
|
164
|
-
const this$: Dictionary<Key, Value> = this;
|
|
165
|
-
return Dictionary__get_Item_2B595<Key, Value>(this$, k);
|
|
166
|
-
}
|
|
167
|
-
has(k: Key): boolean {
|
|
168
|
-
const this$: Dictionary<Key, Value> = this;
|
|
169
|
-
return Dictionary__ContainsKey_2B595<Key, Value>(this$, k);
|
|
170
|
-
}
|
|
171
|
-
keys(): Iterable<Key> {
|
|
172
|
-
const this$: Dictionary<Key, Value> = this;
|
|
173
|
-
return map<[Key, Value], Key>((p: [Key, Value]): Key => p[0], this$);
|
|
174
|
-
}
|
|
175
|
-
set(k: Key, v: Value): IMap<Key, Value> {
|
|
176
|
-
const this$: Dictionary<Key, Value> = this;
|
|
177
|
-
Dictionary__set_Item_5BDDA1<Key, Value>(this$, k, v);
|
|
178
|
-
return this$;
|
|
179
|
-
}
|
|
180
|
-
values(): Iterable<Value> {
|
|
181
|
-
const this$: Dictionary<Key, Value> = this;
|
|
182
|
-
return map<[Key, Value], Value>((p: [Key, Value]): Value => p[1], this$);
|
|
183
|
-
}
|
|
184
|
-
forEach(f: ((arg0: Value, arg1: Key, arg2: IMap<Key, Value>) => void), thisArg?: Option<any>): void {
|
|
185
|
-
const this$: Dictionary<Key, Value> = this;
|
|
186
|
-
iterate<[Key, Value]>((p: [Key, Value]): void => {
|
|
187
|
-
f(p[1], p[0], this$);
|
|
188
|
-
}, this$);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export function Dictionary_$reflection(gen0: TypeInfo, gen1: TypeInfo): TypeInfo {
|
|
193
|
-
return class_type("Fable.Collections.Dictionary", [gen0, gen1], Dictionary);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export function Dictionary_$ctor_6623D9B3<Key, Value>(pairs: Iterable<[Key, Value]>, comparer: IEqualityComparer<Key>): Dictionary<Key, Value> {
|
|
197
|
-
return new Dictionary(pairs, comparer);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function Dictionary__TryFindIndex_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): [boolean, int32, int32] {
|
|
201
|
-
const h: int32 = this$.comparer.GetHashCode(k) | 0;
|
|
202
|
-
let matchValue: [boolean, [Key, Value][]];
|
|
203
|
-
let outArg: [Key, Value][] = defaultOf();
|
|
204
|
-
matchValue = ([tryGetValue(this$.hashMap, h, new FSharpRef<[Key, Value][]>((): [Key, Value][] => outArg, (v: [Key, Value][]): void => {
|
|
205
|
-
outArg = v;
|
|
206
|
-
})), outArg] as [boolean, [Key, Value][]]);
|
|
207
|
-
if (matchValue[0]) {
|
|
208
|
-
return [true, h, matchValue[1].findIndex((pair: [Key, Value]): boolean => this$.comparer.Equals(k, pair[0]))] as [boolean, int32, int32];
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
return [false, h, -1] as [boolean, int32, int32];
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export function Dictionary__TryFind_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): Option<[Key, Value]> {
|
|
216
|
-
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
217
|
-
let matchResult: int32;
|
|
218
|
-
if (matchValue[0]) {
|
|
219
|
-
if (matchValue[2] > -1) {
|
|
220
|
-
matchResult = 0;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
matchResult = 1;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
matchResult = 1;
|
|
228
|
-
}
|
|
229
|
-
switch (matchResult) {
|
|
230
|
-
case 0:
|
|
231
|
-
return getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]];
|
|
232
|
-
default:
|
|
233
|
-
return undefined;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export function Dictionary__get_Comparer<Key, Value>(this$: Dictionary<Key, Value>): IEqualityComparer<Key> {
|
|
238
|
-
return this$.comparer;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export function Dictionary__Clear<Key, Value>(this$: Dictionary<Key, Value>): void {
|
|
242
|
-
this$.hashMap.clear();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export function Dictionary__get_Count<Key, Value>(this$: Dictionary<Key, Value>): int32 {
|
|
246
|
-
let count = 0;
|
|
247
|
-
let enumerator: any = getEnumerator(this$.hashMap.values());
|
|
248
|
-
try {
|
|
249
|
-
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
250
|
-
const pairs: [Key, Value][] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
251
|
-
count = ((count + pairs.length) | 0);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
finally {
|
|
255
|
-
disposeSafe(enumerator);
|
|
256
|
-
}
|
|
257
|
-
return count | 0;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export function Dictionary__get_Item_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): Value {
|
|
261
|
-
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, k);
|
|
262
|
-
if (matchValue != null) {
|
|
263
|
-
return value_1(matchValue)[1];
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
throw new Error("The item was not found in collection");
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export function Dictionary__set_Item_5BDDA1<Key, Value>(this$: Dictionary<Key, Value>, k: Key, v: Value): void {
|
|
271
|
-
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
272
|
-
if (matchValue[0]) {
|
|
273
|
-
if (matchValue[2] > -1) {
|
|
274
|
-
getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]] = ([k, v] as [Key, Value]);
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
const value: any = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v] as [Key, Value]));
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
this$.hashMap.set(matchValue[1], [[k, v] as [Key, Value]]);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export function Dictionary__Add_5BDDA1<Key, Value>(this$: Dictionary<Key, Value>, k: Key, v: Value): void {
|
|
286
|
-
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
287
|
-
if (matchValue[0]) {
|
|
288
|
-
if (matchValue[2] > -1) {
|
|
289
|
-
throw new Error(format("An item with the same key has already been added. Key: {0}", k));
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
const value: any = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v] as [Key, Value]));
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
this$.hashMap.set(matchValue[1], [[k, v] as [Key, Value]]);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export function Dictionary__ContainsKey_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): boolean {
|
|
301
|
-
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
302
|
-
let matchResult: int32;
|
|
303
|
-
if (matchValue[0]) {
|
|
304
|
-
if (matchValue[2] > -1) {
|
|
305
|
-
matchResult = 0;
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
matchResult = 1;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
matchResult = 1;
|
|
313
|
-
}
|
|
314
|
-
switch (matchResult) {
|
|
315
|
-
case 0:
|
|
316
|
-
return true;
|
|
317
|
-
default:
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export function Dictionary__Remove_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): boolean {
|
|
323
|
-
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
324
|
-
let matchResult: int32;
|
|
325
|
-
if (matchValue[0]) {
|
|
326
|
-
if (matchValue[2] > -1) {
|
|
327
|
-
matchResult = 0;
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
matchResult = 1;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
matchResult = 1;
|
|
335
|
-
}
|
|
336
|
-
switch (matchResult) {
|
|
337
|
-
case 0: {
|
|
338
|
-
getItemFromDict(this$.hashMap, matchValue[1]).splice(matchValue[2], 1);
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
default:
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
1
|
+
import { IEqualityComparer, IDisposable, disposeSafe, defaultOf, IMap, equals, toIterator, IEnumerator, getEnumerator } from "./Util.js";
|
|
2
|
+
import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
|
|
3
|
+
import { value as value_1, Option } from "./Option.js";
|
|
4
|
+
import { int32 } from "./Int32.js";
|
|
5
|
+
import { setItem } from "./Array.js";
|
|
6
|
+
import { FSharpRef } from "./Types.js";
|
|
7
|
+
import { class_type, TypeInfo } from "./Reflection.js";
|
|
8
|
+
import { getItemFromDict, tryGetValue } from "./MapUtil.js";
|
|
9
|
+
import { format } from "./String.js";
|
|
10
|
+
|
|
11
|
+
export class Dictionary<Key, Value> implements IMap<Key, Value>, Iterable<[Key, Value]>, Iterable<[Key, Value]> {
|
|
12
|
+
readonly comparer: IEqualityComparer<Key>;
|
|
13
|
+
readonly hashMap: IMap<int32, [Key, Value][]>;
|
|
14
|
+
"init@9": int32;
|
|
15
|
+
constructor(pairs: Iterable<[Key, Value]>, comparer: IEqualityComparer<Key>) {
|
|
16
|
+
const this$: FSharpRef<Dictionary<Key, Value>> = new FSharpRef<Dictionary<Key, Value>>(defaultOf());
|
|
17
|
+
this.comparer = comparer;
|
|
18
|
+
this$.contents = this;
|
|
19
|
+
this.hashMap = (new Map<int32, [Key, Value][]>([]));
|
|
20
|
+
this["init@9"] = 1;
|
|
21
|
+
const enumerator: IEnumerator<[Key, Value]> = getEnumerator(pairs);
|
|
22
|
+
try {
|
|
23
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
24
|
+
const pair: [Key, Value] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
25
|
+
Dictionary__Add_5BDDA1<Key, Value>(this$.contents, pair[0], pair[1]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
disposeSafe(enumerator as IDisposable);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
get [Symbol.toStringTag](): string {
|
|
33
|
+
return "Dictionary";
|
|
34
|
+
}
|
|
35
|
+
toJSON(): any {
|
|
36
|
+
const this$: Dictionary<Key, Value> = this;
|
|
37
|
+
return Array.from(this$);
|
|
38
|
+
}
|
|
39
|
+
"System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any> {
|
|
40
|
+
const this$: Dictionary<Key, Value> = this;
|
|
41
|
+
return getEnumerator(this$);
|
|
42
|
+
}
|
|
43
|
+
GetEnumerator(): IEnumerator<[Key, Value]> {
|
|
44
|
+
const this$: Dictionary<Key, Value> = this;
|
|
45
|
+
return getEnumerator(concat<[Key, Value][], [Key, Value]>(this$.hashMap.values()));
|
|
46
|
+
}
|
|
47
|
+
[Symbol.iterator](): Iterator<[Key, Value]> {
|
|
48
|
+
return toIterator(getEnumerator(this));
|
|
49
|
+
}
|
|
50
|
+
"System.Collections.Generic.ICollection`1.Add2B595"(item: [Key, Value]): void {
|
|
51
|
+
const this$: Dictionary<Key, Value> = this;
|
|
52
|
+
Dictionary__Add_5BDDA1<Key, Value>(this$, item[0], item[1]);
|
|
53
|
+
}
|
|
54
|
+
"System.Collections.Generic.ICollection`1.Clear"(): void {
|
|
55
|
+
const this$: Dictionary<Key, Value> = this;
|
|
56
|
+
Dictionary__Clear<Key, Value>(this$);
|
|
57
|
+
}
|
|
58
|
+
"System.Collections.Generic.ICollection`1.Contains2B595"(item: [Key, Value]): boolean {
|
|
59
|
+
const this$: Dictionary<Key, Value> = this;
|
|
60
|
+
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, item[0]);
|
|
61
|
+
let matchResult: int32, p_1: [Key, Value];
|
|
62
|
+
if (matchValue != null) {
|
|
63
|
+
if (equals(value_1(matchValue)[1], item[1])) {
|
|
64
|
+
matchResult = 0;
|
|
65
|
+
p_1 = value_1(matchValue);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
matchResult = 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
matchResult = 1;
|
|
73
|
+
}
|
|
74
|
+
switch (matchResult) {
|
|
75
|
+
case 0:
|
|
76
|
+
return true;
|
|
77
|
+
default:
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: [Key, Value][], arrayIndex: int32): void {
|
|
82
|
+
const this$: Dictionary<Key, Value> = this;
|
|
83
|
+
iterateIndexed<[Key, Value]>((i: int32, e: [Key, Value]): void => {
|
|
84
|
+
setItem(array, arrayIndex + i, e);
|
|
85
|
+
}, this$);
|
|
86
|
+
}
|
|
87
|
+
"System.Collections.Generic.ICollection`1.get_Count"(): int32 {
|
|
88
|
+
const this$: Dictionary<Key, Value> = this;
|
|
89
|
+
return Dictionary__get_Count<Key, Value>(this$) | 0;
|
|
90
|
+
}
|
|
91
|
+
"System.Collections.Generic.ICollection`1.get_IsReadOnly"(): boolean {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
"System.Collections.Generic.ICollection`1.Remove2B595"(item: [Key, Value]): boolean {
|
|
95
|
+
const this$: Dictionary<Key, Value> = this;
|
|
96
|
+
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, item[0]);
|
|
97
|
+
if (matchValue != null) {
|
|
98
|
+
if (equals(value_1(matchValue)[1], item[1])) {
|
|
99
|
+
Dictionary__Remove_2B595<Key, Value>(this$, item[0]);
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
"System.Collections.Generic.IDictionary`2.Add5BDDA1"(key: Key, value: Value): void {
|
|
108
|
+
const this$: Dictionary<Key, Value> = this;
|
|
109
|
+
Dictionary__Add_5BDDA1<Key, Value>(this$, key, value);
|
|
110
|
+
}
|
|
111
|
+
"System.Collections.Generic.IDictionary`2.ContainsKey2B595"(key: Key): boolean {
|
|
112
|
+
const this$: Dictionary<Key, Value> = this;
|
|
113
|
+
return Dictionary__ContainsKey_2B595<Key, Value>(this$, key);
|
|
114
|
+
}
|
|
115
|
+
"System.Collections.Generic.IDictionary`2.get_Item2B595"(key: Key): Value {
|
|
116
|
+
const this$: Dictionary<Key, Value> = this;
|
|
117
|
+
return Dictionary__get_Item_2B595<Key, Value>(this$, key);
|
|
118
|
+
}
|
|
119
|
+
"System.Collections.Generic.IDictionary`2.set_Item5BDDA1"(key: Key, v: Value): void {
|
|
120
|
+
const this$: Dictionary<Key, Value> = this;
|
|
121
|
+
Dictionary__set_Item_5BDDA1<Key, Value>(this$, key, v);
|
|
122
|
+
}
|
|
123
|
+
"System.Collections.Generic.IDictionary`2.get_Keys"(): Iterable<Key> {
|
|
124
|
+
const this$: Dictionary<Key, Value> = this;
|
|
125
|
+
return toArray<Key>(delay<Key>((): Iterable<Key> => map<[Key, Value], Key>((pair: [Key, Value]): Key => pair[0], this$)));
|
|
126
|
+
}
|
|
127
|
+
"System.Collections.Generic.IDictionary`2.Remove2B595"(key: Key): boolean {
|
|
128
|
+
const this$: Dictionary<Key, Value> = this;
|
|
129
|
+
return Dictionary__Remove_2B595<Key, Value>(this$, key);
|
|
130
|
+
}
|
|
131
|
+
"System.Collections.Generic.IDictionary`2.TryGetValue6DC89625"(key: Key, value: FSharpRef<Value>): boolean {
|
|
132
|
+
const this$: Dictionary<Key, Value> = this;
|
|
133
|
+
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, key);
|
|
134
|
+
if (matchValue != null) {
|
|
135
|
+
const pair: [Key, Value] = value_1(matchValue);
|
|
136
|
+
value.contents = pair[1];
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
"System.Collections.Generic.IDictionary`2.get_Values"(): Iterable<Value> {
|
|
144
|
+
const this$: Dictionary<Key, Value> = this;
|
|
145
|
+
return toArray<Value>(delay<Value>((): Iterable<Value> => map<[Key, Value], Value>((pair: [Key, Value]): Value => pair[1], this$)));
|
|
146
|
+
}
|
|
147
|
+
get size(): int32 {
|
|
148
|
+
const this$: Dictionary<Key, Value> = this;
|
|
149
|
+
return Dictionary__get_Count<Key, Value>(this$) | 0;
|
|
150
|
+
}
|
|
151
|
+
clear(): void {
|
|
152
|
+
const this$: Dictionary<Key, Value> = this;
|
|
153
|
+
Dictionary__Clear<Key, Value>(this$);
|
|
154
|
+
}
|
|
155
|
+
delete(k: Key): boolean {
|
|
156
|
+
const this$: Dictionary<Key, Value> = this;
|
|
157
|
+
return Dictionary__Remove_2B595<Key, Value>(this$, k);
|
|
158
|
+
}
|
|
159
|
+
entries(): Iterable<[Key, Value]> {
|
|
160
|
+
const this$: Dictionary<Key, Value> = this;
|
|
161
|
+
return map<[Key, Value], [Key, Value]>((p: [Key, Value]): [Key, Value] => ([p[0], p[1]] as [Key, Value]), this$);
|
|
162
|
+
}
|
|
163
|
+
get(k: Key): Value {
|
|
164
|
+
const this$: Dictionary<Key, Value> = this;
|
|
165
|
+
return Dictionary__get_Item_2B595<Key, Value>(this$, k);
|
|
166
|
+
}
|
|
167
|
+
has(k: Key): boolean {
|
|
168
|
+
const this$: Dictionary<Key, Value> = this;
|
|
169
|
+
return Dictionary__ContainsKey_2B595<Key, Value>(this$, k);
|
|
170
|
+
}
|
|
171
|
+
keys(): Iterable<Key> {
|
|
172
|
+
const this$: Dictionary<Key, Value> = this;
|
|
173
|
+
return map<[Key, Value], Key>((p: [Key, Value]): Key => p[0], this$);
|
|
174
|
+
}
|
|
175
|
+
set(k: Key, v: Value): IMap<Key, Value> {
|
|
176
|
+
const this$: Dictionary<Key, Value> = this;
|
|
177
|
+
Dictionary__set_Item_5BDDA1<Key, Value>(this$, k, v);
|
|
178
|
+
return this$;
|
|
179
|
+
}
|
|
180
|
+
values(): Iterable<Value> {
|
|
181
|
+
const this$: Dictionary<Key, Value> = this;
|
|
182
|
+
return map<[Key, Value], Value>((p: [Key, Value]): Value => p[1], this$);
|
|
183
|
+
}
|
|
184
|
+
forEach(f: ((arg0: Value, arg1: Key, arg2: IMap<Key, Value>) => void), thisArg?: Option<any>): void {
|
|
185
|
+
const this$: Dictionary<Key, Value> = this;
|
|
186
|
+
iterate<[Key, Value]>((p: [Key, Value]): void => {
|
|
187
|
+
f(p[1], p[0], this$);
|
|
188
|
+
}, this$);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function Dictionary_$reflection(gen0: TypeInfo, gen1: TypeInfo): TypeInfo {
|
|
193
|
+
return class_type("Fable.Collections.Dictionary", [gen0, gen1], Dictionary);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function Dictionary_$ctor_6623D9B3<Key, Value>(pairs: Iterable<[Key, Value]>, comparer: IEqualityComparer<Key>): Dictionary<Key, Value> {
|
|
197
|
+
return new Dictionary(pairs, comparer);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function Dictionary__TryFindIndex_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): [boolean, int32, int32] {
|
|
201
|
+
const h: int32 = this$.comparer.GetHashCode(k) | 0;
|
|
202
|
+
let matchValue: [boolean, [Key, Value][]];
|
|
203
|
+
let outArg: [Key, Value][] = defaultOf();
|
|
204
|
+
matchValue = ([tryGetValue(this$.hashMap, h, new FSharpRef<[Key, Value][]>((): [Key, Value][] => outArg, (v: [Key, Value][]): void => {
|
|
205
|
+
outArg = v;
|
|
206
|
+
})), outArg] as [boolean, [Key, Value][]]);
|
|
207
|
+
if (matchValue[0]) {
|
|
208
|
+
return [true, h, matchValue[1].findIndex((pair: [Key, Value]): boolean => this$.comparer.Equals(k, pair[0]))] as [boolean, int32, int32];
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return [false, h, -1] as [boolean, int32, int32];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function Dictionary__TryFind_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): Option<[Key, Value]> {
|
|
216
|
+
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
217
|
+
let matchResult: int32;
|
|
218
|
+
if (matchValue[0]) {
|
|
219
|
+
if (matchValue[2] > -1) {
|
|
220
|
+
matchResult = 0;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
matchResult = 1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
matchResult = 1;
|
|
228
|
+
}
|
|
229
|
+
switch (matchResult) {
|
|
230
|
+
case 0:
|
|
231
|
+
return getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]];
|
|
232
|
+
default:
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function Dictionary__get_Comparer<Key, Value>(this$: Dictionary<Key, Value>): IEqualityComparer<Key> {
|
|
238
|
+
return this$.comparer;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function Dictionary__Clear<Key, Value>(this$: Dictionary<Key, Value>): void {
|
|
242
|
+
this$.hashMap.clear();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function Dictionary__get_Count<Key, Value>(this$: Dictionary<Key, Value>): int32 {
|
|
246
|
+
let count = 0;
|
|
247
|
+
let enumerator: any = getEnumerator(this$.hashMap.values());
|
|
248
|
+
try {
|
|
249
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
250
|
+
const pairs: [Key, Value][] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
251
|
+
count = ((count + pairs.length) | 0);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
disposeSafe(enumerator);
|
|
256
|
+
}
|
|
257
|
+
return count | 0;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function Dictionary__get_Item_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): Value {
|
|
261
|
+
const matchValue: Option<[Key, Value]> = Dictionary__TryFind_2B595<Key, Value>(this$, k);
|
|
262
|
+
if (matchValue != null) {
|
|
263
|
+
return value_1(matchValue)[1];
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
throw new Error("The item was not found in collection");
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function Dictionary__set_Item_5BDDA1<Key, Value>(this$: Dictionary<Key, Value>, k: Key, v: Value): void {
|
|
271
|
+
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
272
|
+
if (matchValue[0]) {
|
|
273
|
+
if (matchValue[2] > -1) {
|
|
274
|
+
getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]] = ([k, v] as [Key, Value]);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
const value: any = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v] as [Key, Value]));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
this$.hashMap.set(matchValue[1], [[k, v] as [Key, Value]]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function Dictionary__Add_5BDDA1<Key, Value>(this$: Dictionary<Key, Value>, k: Key, v: Value): void {
|
|
286
|
+
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
287
|
+
if (matchValue[0]) {
|
|
288
|
+
if (matchValue[2] > -1) {
|
|
289
|
+
throw new Error(format("An item with the same key has already been added. Key: {0}", k));
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const value: any = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v] as [Key, Value]));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
this$.hashMap.set(matchValue[1], [[k, v] as [Key, Value]]);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function Dictionary__ContainsKey_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): boolean {
|
|
301
|
+
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
302
|
+
let matchResult: int32;
|
|
303
|
+
if (matchValue[0]) {
|
|
304
|
+
if (matchValue[2] > -1) {
|
|
305
|
+
matchResult = 0;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
matchResult = 1;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
matchResult = 1;
|
|
313
|
+
}
|
|
314
|
+
switch (matchResult) {
|
|
315
|
+
case 0:
|
|
316
|
+
return true;
|
|
317
|
+
default:
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function Dictionary__Remove_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): boolean {
|
|
323
|
+
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
324
|
+
let matchResult: int32;
|
|
325
|
+
if (matchValue[0]) {
|
|
326
|
+
if (matchValue[2] > -1) {
|
|
327
|
+
matchResult = 0;
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
matchResult = 1;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
matchResult = 1;
|
|
335
|
+
}
|
|
336
|
+
switch (matchResult) {
|
|
337
|
+
case 0: {
|
|
338
|
+
getItemFromDict(this$.hashMap, matchValue[1]).splice(matchValue[2], 1);
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
default:
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|