@shd101wyy/yo 0.1.26 → 0.1.27
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/.github/skills/yo-async-effects/SKILL.md +4 -4
- package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
- package/.github/skills/yo-core-patterns/SKILL.md +1 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -26
- package/.github/skills/yo-project-workflow/SKILL.md +6 -3
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
- package/.github/skills/yo-syntax/SKILL.md +7 -6
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +73 -60
- package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
- package/README.md +10 -8
- package/out/cjs/index.cjs +456 -438
- package/out/cjs/yo-cli.cjs +576 -543
- package/out/cjs/yo-lsp.cjs +559 -532
- package/out/esm/index.mjs +281 -263
- package/out/types/src/formatter.d.ts +11 -0
- package/out/types/src/lsp/formatting.d.ts +2 -0
- package/out/types/src/tests/formatter.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/alg/hash.yo +13 -21
- package/std/allocator.yo +25 -40
- package/std/async.yo +3 -7
- package/std/build.yo +105 -151
- package/std/cli/arg_parser.yo +184 -169
- package/std/collections/array_list.yo +350 -314
- package/std/collections/btree_map.yo +142 -131
- package/std/collections/deque.yo +132 -128
- package/std/collections/hash_map.yo +542 -566
- package/std/collections/hash_set.yo +623 -687
- package/std/collections/linked_list.yo +275 -293
- package/std/collections/ordered_map.yo +113 -85
- package/std/collections/priority_queue.yo +73 -73
- package/std/crypto/md5.yo +191 -95
- package/std/crypto/random.yo +56 -64
- package/std/crypto/sha256.yo +151 -107
- package/std/encoding/base64.yo +87 -81
- package/std/encoding/hex.yo +43 -50
- package/std/encoding/html.yo +56 -81
- package/std/encoding/html_char_utils.yo +7 -13
- package/std/encoding/html_entities.yo +2248 -2253
- package/std/encoding/json.yo +316 -224
- package/std/encoding/punycode.yo +86 -116
- package/std/encoding/toml.yo +67 -66
- package/std/encoding/utf16.yo +37 -44
- package/std/env.yo +62 -91
- package/std/error.yo +7 -15
- package/std/fmt/display.yo +5 -9
- package/std/fmt/index.yo +8 -14
- package/std/fmt/to_string.yo +330 -315
- package/std/fmt/writer.yo +58 -87
- package/std/fs/dir.yo +83 -102
- package/std/fs/file.yo +147 -180
- package/std/fs/metadata.yo +45 -78
- package/std/fs/temp.yo +55 -65
- package/std/fs/types.yo +27 -40
- package/std/fs/walker.yo +53 -68
- package/std/gc.yo +5 -8
- package/std/glob.yo +30 -43
- package/std/http/client.yo +107 -120
- package/std/http/http.yo +106 -96
- package/std/http/index.yo +4 -6
- package/std/imm/list.yo +88 -93
- package/std/imm/map.yo +528 -464
- package/std/imm/set.yo +52 -57
- package/std/imm/sorted_map.yo +340 -286
- package/std/imm/sorted_set.yo +57 -63
- package/std/imm/string.yo +404 -345
- package/std/imm/vec.yo +173 -181
- package/std/io/reader.yo +3 -6
- package/std/io/writer.yo +4 -8
- package/std/libc/assert.yo +5 -9
- package/std/libc/ctype.yo +32 -22
- package/std/libc/dirent.yo +26 -25
- package/std/libc/errno.yo +164 -90
- package/std/libc/fcntl.yo +52 -45
- package/std/libc/float.yo +66 -44
- package/std/libc/limits.yo +42 -33
- package/std/libc/math.yo +53 -82
- package/std/libc/signal.yo +72 -47
- package/std/libc/stdatomic.yo +217 -188
- package/std/libc/stdint.yo +5 -29
- package/std/libc/stdio.yo +5 -29
- package/std/libc/stdlib.yo +32 -39
- package/std/libc/string.yo +5 -23
- package/std/libc/sys/stat.yo +58 -56
- package/std/libc/time.yo +5 -19
- package/std/libc/unistd.yo +5 -20
- package/std/libc/wctype.yo +6 -9
- package/std/libc/windows.yo +26 -30
- package/std/log.yo +41 -55
- package/std/net/addr.yo +102 -97
- package/std/net/dns.yo +27 -28
- package/std/net/errors.yo +50 -49
- package/std/net/tcp.yo +113 -124
- package/std/net/udp.yo +55 -66
- package/std/os/env.yo +35 -33
- package/std/os/signal.yo +15 -25
- package/std/path.yo +276 -311
- package/std/prelude.yo +6304 -4315
- package/std/process/command.yo +87 -103
- package/std/process/index.yo +12 -31
- package/std/regex/compiler.yo +196 -95
- package/std/regex/flags.yo +58 -39
- package/std/regex/index.yo +157 -173
- package/std/regex/match.yo +20 -31
- package/std/regex/node.yo +134 -152
- package/std/regex/parser.yo +283 -259
- package/std/regex/unicode.yo +172 -202
- package/std/regex/vm.yo +155 -171
- package/std/string/index.yo +5 -7
- package/std/string/rune.yo +45 -55
- package/std/string/string.yo +937 -964
- package/std/string/string_builder.yo +94 -104
- package/std/string/unicode.yo +46 -64
- package/std/sync/channel.yo +72 -73
- package/std/sync/cond.yo +31 -36
- package/std/sync/mutex.yo +30 -32
- package/std/sync/once.yo +13 -16
- package/std/sync/rwlock.yo +26 -31
- package/std/sync/waitgroup.yo +20 -25
- package/std/sys/advise.yo +16 -24
- package/std/sys/bufio/buf_reader.yo +77 -93
- package/std/sys/bufio/buf_writer.yo +52 -65
- package/std/sys/clock.yo +4 -9
- package/std/sys/constants.yo +77 -61
- package/std/sys/copy.yo +4 -10
- package/std/sys/dir.yo +26 -43
- package/std/sys/dns.yo +41 -61
- package/std/sys/errors.yo +95 -103
- package/std/sys/events.yo +45 -57
- package/std/sys/externs.yo +319 -267
- package/std/sys/fallocate.yo +7 -11
- package/std/sys/fcntl.yo +14 -22
- package/std/sys/file.yo +26 -40
- package/std/sys/future.yo +5 -8
- package/std/sys/iov.yo +12 -25
- package/std/sys/lock.yo +12 -13
- package/std/sys/mmap.yo +38 -43
- package/std/sys/path.yo +3 -8
- package/std/sys/perm.yo +7 -21
- package/std/sys/pipe.yo +5 -12
- package/std/sys/process.yo +23 -29
- package/std/sys/seek.yo +10 -12
- package/std/sys/signal.yo +7 -13
- package/std/sys/signals.yo +52 -35
- package/std/sys/socket.yo +63 -58
- package/std/sys/socketpair.yo +3 -6
- package/std/sys/sockinfo.yo +11 -20
- package/std/sys/statfs.yo +11 -34
- package/std/sys/statx.yo +25 -52
- package/std/sys/sysinfo.yo +15 -20
- package/std/sys/tcp.yo +62 -92
- package/std/sys/temp.yo +5 -9
- package/std/sys/time.yo +5 -15
- package/std/sys/timer.yo +6 -11
- package/std/sys/tty.yo +10 -18
- package/std/sys/udp.yo +22 -39
- package/std/sys/umask.yo +3 -6
- package/std/sys/unix.yo +33 -52
- package/std/testing/bench.yo +49 -52
- package/std/thread.yo +10 -15
- package/std/time/datetime.yo +105 -89
- package/std/time/duration.yo +43 -56
- package/std/time/instant.yo +13 -18
- package/std/time/sleep.yo +5 -9
- package/std/url/index.yo +184 -209
- package/std/worker.yo +6 -10
|
@@ -10,20 +10,15 @@
|
|
|
10
10
|
//! m.set(String.from("a"), 1);
|
|
11
11
|
//! // Iteration order: a, b
|
|
12
12
|
//! ```
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
open import "../string";
|
|
16
|
-
|
|
13
|
+
{ ArrayList } :: import("./array_list");
|
|
14
|
+
open(import("../string"));
|
|
17
15
|
/// Key-value pair entry stored in a BTreeMap.
|
|
18
16
|
BTreeEntry :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
19
|
-
struct(key: K, value: V)
|
|
17
|
+
struct(key : K, value : V)
|
|
20
18
|
);
|
|
21
|
-
|
|
22
|
-
export BTreeEntry;
|
|
23
|
-
|
|
19
|
+
export(BTreeEntry);
|
|
24
20
|
// Internal result from binary search.
|
|
25
|
-
_FindResult :: struct(idx: usize, found: bool);
|
|
26
|
-
|
|
21
|
+
_FindResult :: struct(idx : usize, found : bool);
|
|
27
22
|
/// Sorted map maintaining entries in key order.
|
|
28
23
|
/// Provides ordered iteration and O(log n) lookup via binary search. Insert is O(n).
|
|
29
24
|
BTreeMap :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
@@ -31,74 +26,75 @@ BTreeMap :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
|
31
26
|
_entries : ArrayList(BTreeEntry(K, V))
|
|
32
27
|
)
|
|
33
28
|
);
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
impl(
|
|
30
|
+
forall(K : Type, V : Type),
|
|
31
|
+
BTreeMap(K, V),
|
|
36
32
|
// Create an empty map.
|
|
37
33
|
new : (fn() -> Self)(
|
|
38
|
-
Self(_entries: ArrayList(BTreeEntry(K, V)).new())
|
|
34
|
+
Self(_entries : ArrayList(BTreeEntry(K, V)).new())
|
|
39
35
|
),
|
|
40
|
-
|
|
41
36
|
// Number of entries.
|
|
42
|
-
len : (fn(self: Self) -> usize)(
|
|
37
|
+
len : (fn(self : Self) -> usize)(
|
|
43
38
|
self._entries.len()
|
|
44
39
|
),
|
|
45
|
-
|
|
46
40
|
// True if empty.
|
|
47
|
-
is_empty : (fn(self: Self) -> bool)(
|
|
48
|
-
|
|
41
|
+
is_empty : (fn(self : Self) -> bool)(
|
|
42
|
+
self._entries.len() == usize(0)
|
|
49
43
|
),
|
|
50
|
-
|
|
51
44
|
// Binary search: returns the index of the entry with key `k`,
|
|
52
45
|
// or the insertion point if not found.
|
|
53
|
-
_find : (fn(self: Self, k: K, where(K <: Ord(K))) -> _FindResult)({
|
|
46
|
+
_find : (fn(self : Self, k : K, where(K <: Ord(K))) -> _FindResult)({
|
|
54
47
|
lo := usize(0);
|
|
55
48
|
hi := self._entries.len();
|
|
56
|
-
while
|
|
49
|
+
while(lo < hi, {
|
|
57
50
|
mid := (lo + ((hi - lo) / usize(2)));
|
|
58
51
|
entry_key := self._entries.get(mid).unwrap().key;
|
|
59
52
|
cond(
|
|
60
|
-
(entry_key < k) => {
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
(entry_key < k) => {
|
|
54
|
+
lo = (mid + usize(1));
|
|
55
|
+
},
|
|
56
|
+
(entry_key > k) => {
|
|
57
|
+
hi = mid;
|
|
58
|
+
},
|
|
59
|
+
true => {
|
|
60
|
+
return(_FindResult(mid, true));
|
|
61
|
+
}
|
|
63
62
|
);
|
|
64
|
-
};
|
|
63
|
+
});
|
|
65
64
|
_FindResult(lo, false)
|
|
66
65
|
}),
|
|
67
|
-
|
|
68
66
|
// Retrieve the value associated with key `k`.
|
|
69
|
-
get : (fn(self: Self, k: K, where(K <: Ord(K))) -> ?V)({
|
|
67
|
+
get : (fn(self : Self, k : K, where(K <: Ord(K))) -> ?(V))({
|
|
70
68
|
r := self._find(k);
|
|
71
69
|
cond(
|
|
72
|
-
r.found
|
|
73
|
-
true
|
|
70
|
+
r.found =>.Some(self._entries.get(r.idx).unwrap().value),
|
|
71
|
+
true =>.None
|
|
74
72
|
)
|
|
75
73
|
}),
|
|
76
|
-
|
|
77
74
|
// Insert or update the value for key `k`.
|
|
78
75
|
// For new keys: append at end then shift-left to correct sorted position.
|
|
79
|
-
set : (fn(self: Self, k: K, v: V, where(K <: Ord(K))) -> unit)({
|
|
76
|
+
set : (fn(self : Self, k : K, v : V, where(K <: Ord(K))) -> unit)({
|
|
80
77
|
r := self._find(k);
|
|
81
78
|
cond(
|
|
82
79
|
r.found => {
|
|
83
80
|
entry := self._entries.get(r.idx).unwrap();
|
|
84
|
-
&(self._entries(r.idx)).* = BTreeEntry(K, V)(key: entry.key, value: v);
|
|
81
|
+
&(self._entries(r.idx)).* = BTreeEntry(K, V)(key : entry.key, value : v);
|
|
85
82
|
},
|
|
86
83
|
true => {
|
|
87
84
|
// Append new entry then bubble left to sorted position
|
|
88
|
-
self._entries.push(BTreeEntry(K, V)(key: k, value: v));
|
|
85
|
+
self._entries.push(BTreeEntry(K, V)(key : k, value : v));
|
|
89
86
|
pos := (self._entries.len() - usize(1));
|
|
90
|
-
while
|
|
87
|
+
while(pos > r.idx, pos = (pos - usize(1)), {
|
|
91
88
|
curr := self._entries.get(pos).unwrap();
|
|
92
|
-
prev := self._entries.get(
|
|
89
|
+
prev := self._entries.get(pos - usize(1)).unwrap();
|
|
93
90
|
&(self._entries(pos)).* = prev;
|
|
94
|
-
&(self._entries(
|
|
95
|
-
};
|
|
91
|
+
&(self._entries(pos - usize(1))).* = curr;
|
|
92
|
+
});
|
|
96
93
|
}
|
|
97
94
|
);
|
|
98
95
|
}),
|
|
99
|
-
|
|
100
96
|
// Remove the entry with key `k`. Returns the old value, or .None.
|
|
101
|
-
remove : (fn(self: Self, k: K, where(K <: Ord(K))) -> ?V)({
|
|
97
|
+
remove : (fn(self : Self, k : K, where(K <: Ord(K))) -> ?(V))({
|
|
102
98
|
r := self._find(k);
|
|
103
99
|
cond(
|
|
104
100
|
r.found => {
|
|
@@ -106,155 +102,170 @@ impl(forall(K : Type, V : Type), BTreeMap(K, V),
|
|
|
106
102
|
self._entries.remove(r.idx);
|
|
107
103
|
.Some(v)
|
|
108
104
|
},
|
|
109
|
-
true
|
|
105
|
+
true =>.None
|
|
110
106
|
)
|
|
111
107
|
}),
|
|
112
|
-
|
|
113
108
|
// Return the entry with the smallest key, or .None.
|
|
114
|
-
min : (fn(self: Self) -> ?BTreeEntry(K, V))(
|
|
109
|
+
min : (fn(self : Self) -> ?(BTreeEntry(K, V)))(
|
|
115
110
|
cond(
|
|
116
|
-
(self._entries.len() == usize(0))
|
|
117
|
-
true
|
|
111
|
+
(self._entries.len() == usize(0)) =>.None,
|
|
112
|
+
true =>.Some(self._entries.get(usize(0)).unwrap())
|
|
118
113
|
)
|
|
119
114
|
),
|
|
120
|
-
|
|
121
115
|
// Return the entry with the largest key, or .None.
|
|
122
|
-
max : (fn(self: Self) -> ?BTreeEntry(K, V))(
|
|
116
|
+
max : (fn(self : Self) -> ?(BTreeEntry(K, V)))(
|
|
123
117
|
cond(
|
|
124
|
-
(self._entries.len() == usize(0))
|
|
125
|
-
true
|
|
118
|
+
(self._entries.len() == usize(0)) =>.None,
|
|
119
|
+
true =>.Some(self._entries.get(self._entries.len() - usize(1)).unwrap())
|
|
126
120
|
)
|
|
127
121
|
)
|
|
128
122
|
);
|
|
129
|
-
|
|
130
123
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
* Value iterator for BTreeMap - yields BTreeEntry(K, V) in sorted key order
|
|
125
|
+
*/
|
|
133
126
|
BTreeMapIter :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
134
127
|
struct(
|
|
135
128
|
_entries : ArrayList(BTreeEntry(K, V)),
|
|
136
|
-
_index
|
|
129
|
+
_index : usize
|
|
137
130
|
)
|
|
138
131
|
);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
impl(
|
|
133
|
+
forall(K : Type, V : Type),
|
|
134
|
+
BTreeMapIter(K, V),
|
|
135
|
+
Iterator(
|
|
136
|
+
Item : BTreeEntry(K, V),
|
|
137
|
+
next : (fn(self : *(Self)) -> Option(BTreeEntry(K, V)))(
|
|
138
|
+
cond(
|
|
139
|
+
(self._index >= self._entries.len()) =>.None,
|
|
140
|
+
true => {
|
|
141
|
+
entry := self._entries.get(self._index).unwrap();
|
|
142
|
+
self._index = (self._index + usize(1));
|
|
143
|
+
.Some(entry)
|
|
144
|
+
}
|
|
145
|
+
)
|
|
150
146
|
)
|
|
151
147
|
)
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
);
|
|
149
|
+
impl(
|
|
150
|
+
forall(K : Type, V : Type),
|
|
151
|
+
BTreeMap(K, V),
|
|
155
152
|
into_iter : (fn(self : Self) -> BTreeMapIter(K, V))(
|
|
156
|
-
BTreeMapIter(K, V)(_entries: self._entries, _index: usize(0))
|
|
153
|
+
BTreeMapIter(K, V)(_entries : self._entries, _index : usize(0))
|
|
157
154
|
)
|
|
158
155
|
);
|
|
159
|
-
|
|
160
156
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
* Pointer iterator for BTreeMap - yields pointers to BTreeEntry(K, V) in sorted key order
|
|
158
|
+
*/
|
|
163
159
|
BTreeMapIterPtr :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
164
160
|
struct(
|
|
165
161
|
_entries : ArrayList(BTreeEntry(K, V)),
|
|
166
|
-
_index
|
|
162
|
+
_index : usize
|
|
167
163
|
)
|
|
168
164
|
);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
self.
|
|
180
|
-
.Some(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
165
|
+
impl(
|
|
166
|
+
forall(K : Type, V : Type),
|
|
167
|
+
BTreeMapIterPtr(K, V),
|
|
168
|
+
Iterator(
|
|
169
|
+
Item : *(BTreeEntry(K, V)),
|
|
170
|
+
next : (fn(self : *(Self)) -> Option(*(BTreeEntry(K, V))))(
|
|
171
|
+
cond(
|
|
172
|
+
(self._index >= self._entries.len()) =>.None,
|
|
173
|
+
true =>
|
|
174
|
+
match(
|
|
175
|
+
self._entries._ptr,
|
|
176
|
+
.Some(ptr) => {
|
|
177
|
+
element_ptr := (ptr &+ self._index);
|
|
178
|
+
self._index = (self._index + usize(1));
|
|
179
|
+
.Some(element_ptr)
|
|
180
|
+
},
|
|
181
|
+
.None =>.None
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
184
|
)
|
|
185
185
|
)
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
);
|
|
187
|
+
impl(
|
|
188
|
+
forall(K : Type, V : Type),
|
|
189
|
+
BTreeMap(K, V),
|
|
189
190
|
iter : (fn(self : *(Self)) -> BTreeMapIterPtr(K, V))(
|
|
190
|
-
BTreeMapIterPtr(K, V)(_entries: self.*._entries, _index: usize(0))
|
|
191
|
+
BTreeMapIterPtr(K, V)(_entries : self.*._entries, _index : usize(0))
|
|
191
192
|
)
|
|
192
193
|
);
|
|
193
|
-
|
|
194
194
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
* Keys iterator - wraps BTreeMapIter and yields only keys in sorted order
|
|
196
|
+
*/
|
|
197
197
|
BTreeMapKeys :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
198
198
|
struct(
|
|
199
199
|
_inner : BTreeMapIter(K, V)
|
|
200
200
|
)
|
|
201
201
|
);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
202
|
+
impl(
|
|
203
|
+
forall(K : Type, V : Type),
|
|
204
|
+
BTreeMapKeys(K, V),
|
|
205
|
+
Iterator(
|
|
206
|
+
Item : K,
|
|
207
|
+
next : (fn(self : *(Self)) -> Option(K))(
|
|
208
|
+
match(
|
|
209
|
+
self._inner.next(),
|
|
210
|
+
.None =>.None,
|
|
211
|
+
.Some(entry) =>.Some(entry.key)
|
|
212
|
+
)
|
|
209
213
|
)
|
|
210
214
|
)
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
);
|
|
216
|
+
impl(
|
|
217
|
+
forall(K : Type, V : Type),
|
|
218
|
+
BTreeMap(K, V),
|
|
214
219
|
keys : (fn(self : Self) -> BTreeMapKeys(K, V))(
|
|
215
|
-
BTreeMapKeys(K, V)(_inner: BTreeMapIter(K, V)(_entries: self._entries, _index: usize(0)))
|
|
220
|
+
BTreeMapKeys(K, V)(_inner : BTreeMapIter(K, V)(_entries : self._entries, _index : usize(0)))
|
|
216
221
|
)
|
|
217
222
|
);
|
|
218
|
-
|
|
219
223
|
/**
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
* Values iterator - wraps BTreeMapIter and yields only values in sorted key order
|
|
225
|
+
*/
|
|
222
226
|
BTreeMapValues :: (fn(comptime(K) : Type, comptime(V) : Type) -> comptime(Type))(
|
|
223
227
|
struct(
|
|
224
228
|
_inner : BTreeMapIter(K, V)
|
|
225
229
|
)
|
|
226
230
|
);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
impl(
|
|
232
|
+
forall(K : Type, V : Type),
|
|
233
|
+
BTreeMapValues(K, V),
|
|
234
|
+
Iterator(
|
|
235
|
+
Item : V,
|
|
236
|
+
next : (fn(self : *(Self)) -> Option(V))(
|
|
237
|
+
match(
|
|
238
|
+
self._inner.next(),
|
|
239
|
+
.None =>.None,
|
|
240
|
+
.Some(entry) =>.Some(entry.value)
|
|
241
|
+
)
|
|
234
242
|
)
|
|
235
243
|
)
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
|
|
244
|
+
);
|
|
245
|
+
impl(
|
|
246
|
+
forall(K : Type, V : Type),
|
|
247
|
+
BTreeMap(K, V),
|
|
239
248
|
values : (fn(self : Self) -> BTreeMapValues(K, V))(
|
|
240
|
-
BTreeMapValues(K, V)(_inner: BTreeMapIter(K, V)(_entries: self._entries, _index: usize(0)))
|
|
249
|
+
BTreeMapValues(K, V)(_inner : BTreeMapIter(K, V)(_entries : self._entries, _index : usize(0)))
|
|
241
250
|
)
|
|
242
251
|
);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
)
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
impl(
|
|
253
|
+
forall(K : Type, V : Type),
|
|
254
|
+
BTreeMap(K, V),
|
|
255
|
+
Index(K)(
|
|
256
|
+
Output : V,
|
|
257
|
+
index : (fn(self : *(Self), idx : K, where(K <: Ord(K))) -> *(Self.Output))({
|
|
258
|
+
r := self.*._find(idx);
|
|
259
|
+
assert(r.found, "BTreeMap: key not found");
|
|
260
|
+
entry_ptr := &(self.*._entries(r.idx));
|
|
261
|
+
&(entry_ptr.*.value)
|
|
262
|
+
})
|
|
263
|
+
)
|
|
264
|
+
);
|
|
265
|
+
export(
|
|
255
266
|
BTreeMap,
|
|
256
267
|
BTreeMapIter,
|
|
257
268
|
BTreeMapIterPtr,
|
|
258
269
|
BTreeMapKeys,
|
|
259
270
|
BTreeMapValues
|
|
260
|
-
;
|
|
271
|
+
);
|