mt-lang 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/docs/index.html +4 -3
- data/lib/milk_tea/base.rb +1 -1
- data/std/asset_pack.mt +267 -0
- data/std/async/libuv_runtime.mt +539 -0
- data/std/async/mailbox.mt +191 -0
- data/std/async/runtime.mt +87 -0
- data/std/async.mt +87 -0
- data/std/base64.mt +185 -0
- data/std/behavior_tree.mt +396 -0
- data/std/binary.mt +314 -0
- data/std/binary_heap.mt +157 -0
- data/std/bitset.mt +239 -0
- data/std/box2d.mt +535 -0
- data/std/bytes.mt +46 -0
- data/std/c/box2d.mt +1254 -0
- data/std/c/cgltf.mt +647 -0
- data/std/c/cjson.mt +106 -0
- data/std/c/crypto.mt +11 -0
- data/std/c/crypto_support.h +51 -0
- data/std/c/ctype.mt +19 -0
- data/std/c/ctype_bindgen.h +29 -0
- data/std/c/curl.mt +1223 -0
- data/std/c/enet.mt +473 -0
- data/std/c/errno.mt +41 -0
- data/std/c/errno_bindgen.h +53 -0
- data/std/c/flecs.mt +2945 -0
- data/std/c/fs.linux.mt +43 -0
- data/std/c/fs.windows.mt +43 -0
- data/std/c/fs_support.h +954 -0
- data/std/c/gl.mt +2065 -0
- data/std/c/gl_registry_helpers.h +10748 -0
- data/std/c/glfw.mt +499 -0
- data/std/c/libc.mt +167 -0
- data/std/c/libuv.mt +1491 -0
- data/std/c/math.mt +22 -0
- data/std/c/math_bindgen.h +31 -0
- data/std/c/miniaudio.mt +3420 -0
- data/std/c/pcre2.mt +735 -0
- data/std/c/process.mt +58 -0
- data/std/c/process_support.h +1147 -0
- data/std/c/raygui.mt +1602 -0
- data/std/c/raylib.mt +1245 -0
- data/std/c/raymath.mt +163 -0
- data/std/c/rlgl.mt +434 -0
- data/std/c/rpng.mt +60 -0
- data/std/c/rres.mt +187 -0
- data/std/c/sdl3.mt +4132 -0
- data/std/c/sqlite3.mt +951 -0
- data/std/c/stb_image.mt +52 -0
- data/std/c/stb_image_resize2.mt +128 -0
- data/std/c/stb_image_write.mt +19 -0
- data/std/c/stb_rect_pack.mt +38 -0
- data/std/c/stb_truetype.mt +175 -0
- data/std/c/stb_vorbis.mt +31 -0
- data/std/c/stdio.mt +90 -0
- data/std/c/steamworks.h +5769 -0
- data/std/c/steamworks.mt +4771 -0
- data/std/c/string.mt +16 -0
- data/std/c/string_bindgen.h +36 -0
- data/std/c/sync.mt +33 -0
- data/std/c/sync_support.h +219 -0
- data/std/c/terminal.mt +24 -0
- data/std/c/terminal_support.h +408 -0
- data/std/c/time.mt +26 -0
- data/std/c/tls.mt +24 -0
- data/std/c/tls_support.h +626 -0
- data/std/c/tracy.mt +53 -0
- data/std/c/zlib.mt +20 -0
- data/std/c/zlib_support.h +239 -0
- data/std/c/zstd.mt +231 -0
- data/std/cell.mt +60 -0
- data/std/cgltf.mt +115 -0
- data/std/cjson.mt +90 -0
- data/std/cli.mt +768 -0
- data/std/cookie.mt +198 -0
- data/std/counter.mt +160 -0
- data/std/crypto.mt +74 -0
- data/std/cstring.mt +13 -0
- data/std/ctype.mt +52 -0
- data/std/curl/runtime.mt +261 -0
- data/std/curl.mt +38 -0
- data/std/deque.mt +348 -0
- data/std/encoding.mt +93 -0
- data/std/enet.mt +133 -0
- data/std/env.mt +41 -0
- data/std/errno.mt +47 -0
- data/std/flecs.mt +978 -0
- data/std/fmt.mt +271 -0
- data/std/fs.linux.mt +696 -0
- data/std/fs.windows.mt +711 -0
- data/std/fsm.mt +267 -0
- data/std/gl.mt +2062 -0
- data/std/glfw.mt +471 -0
- data/std/goap.mt +342 -0
- data/std/graph.mt +521 -0
- data/std/gzip.mt +77 -0
- data/std/hash.mt +429 -0
- data/std/http/server.mt +810 -0
- data/std/http.mt +1227 -0
- data/std/intern.mt +53 -0
- data/std/jobs.mt +288 -0
- data/std/json.mt +627 -0
- data/std/libc.mt +34 -0
- data/std/libuv.mt +554 -0
- data/std/linear_algebra.mt +243 -0
- data/std/linked_map.mt +372 -0
- data/std/linked_map_view.mt +49 -0
- data/std/linked_set.mt +117 -0
- data/std/log.mt +69 -0
- data/std/map.mt +418 -0
- data/std/math.mt +24 -0
- data/std/mem/arena.mt +137 -0
- data/std/mem/endian.mt +51 -0
- data/std/mem/heap.mt +298 -0
- data/std/mem/pool.mt +164 -0
- data/std/mem/stack.mt +47 -0
- data/std/mem/tracking.mt +119 -0
- data/std/miniaudio.mt +1299 -0
- data/std/multiset.mt +191 -0
- data/std/net/channel.mt +727 -0
- data/std/net/clock.mt +237 -0
- data/std/net/discovery.mt +277 -0
- data/std/net/lobby.mt +813 -0
- data/std/net/manager.mt +539 -0
- data/std/net/mux.mt +839 -0
- data/std/net/nat.mt +122 -0
- data/std/net/packet.mt +219 -0
- data/std/net/punch.mt +162 -0
- data/std/net/rpc.mt +119 -0
- data/std/net/session.mt +1157 -0
- data/std/net/stun.mt +252 -0
- data/std/net/sync.mt +183 -0
- data/std/net/turn.mt +459 -0
- data/std/net.mt +2944 -0
- data/std/oauth2.mt +408 -0
- data/std/option.mt +51 -0
- data/std/ordered_map.mt +497 -0
- data/std/ordered_set.mt +348 -0
- data/std/path.mt +368 -0
- data/std/pcre2/runtime.mt +35 -0
- data/std/pcre2.mt +78 -0
- data/std/priority_queue.mt +55 -0
- data/std/process.mt +837 -0
- data/std/queue.mt +55 -0
- data/std/random.mt +146 -0
- data/std/raygui.mt +99 -0
- data/std/raylib/debug_console.mt +71 -0
- data/std/raylib/easing.mt +388 -0
- data/std/raylib/packed_assets.mt +255 -0
- data/std/raylib/runtime.mt +30 -0
- data/std/raylib/tracy_gpu.mt +37 -0
- data/std/raylib.mt +1510 -0
- data/std/raymath.mt +153 -0
- data/std/result.mt +89 -0
- data/std/rlgl.mt +268 -0
- data/std/rpng.mt +46 -0
- data/std/rres.mt +36 -0
- data/std/sdl3/runtime.mt +54 -0
- data/std/sdl3.mt +1731 -0
- data/std/serialize.mt +68 -0
- data/std/set.mt +124 -0
- data/std/spatial.mt +176 -0
- data/std/sqlite3.mt +151 -0
- data/std/stack.mt +55 -0
- data/std/stb_image.mt +47 -0
- data/std/stb_image_resize2.mt +41 -0
- data/std/stb_image_write.mt +17 -0
- data/std/stb_rect_pack.mt +15 -0
- data/std/stb_truetype.mt +77 -0
- data/std/stb_vorbis.mt +16 -0
- data/std/stdio.mt +88 -0
- data/std/steamworks.mt +1542 -0
- data/std/str.mt +293 -0
- data/std/string.mt +234 -0
- data/std/sync.mt +194 -0
- data/std/tar.mt +704 -0
- data/std/terminal.mt +1002 -0
- data/std/testing.mt +266 -0
- data/std/thread.mt +120 -0
- data/std/time.mt +105 -0
- data/std/tls.mt +616 -0
- data/std/toml.mt +1310 -0
- data/std/tracy.mt +42 -0
- data/std/uri.mt +118 -0
- data/std/url.mt +372 -0
- data/std/vec.mt +433 -0
- data/std/zstd.mt +94 -0
- metadata +187 -2
data/std/multiset.mt
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import std.counter as counter
|
|
2
|
+
import std.linked_map as linked_map
|
|
3
|
+
import std.linked_map_view as linked_map_view
|
|
4
|
+
|
|
5
|
+
public struct Entry[T]:
|
|
6
|
+
value: const_ptr[T]
|
|
7
|
+
count: ptr_uint
|
|
8
|
+
|
|
9
|
+
public struct Entries[T]:
|
|
10
|
+
values: linked_map_view.SnapshotEntries[T, ptr_uint]
|
|
11
|
+
|
|
12
|
+
public struct MultiSet[T]:
|
|
13
|
+
values: counter.Counter[T]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
extending MultiSet[T]:
|
|
17
|
+
public static function create() -> MultiSet[T]:
|
|
18
|
+
return MultiSet[T](values = counter.Counter[T].create())
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
public static function with_capacity(capacity: ptr_uint) -> MultiSet[T]:
|
|
22
|
+
var result = MultiSet[T].create()
|
|
23
|
+
result.reserve(capacity)
|
|
24
|
+
return result
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function len() -> ptr_uint:
|
|
28
|
+
return this.values.total_count()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public function total_count() -> ptr_uint:
|
|
32
|
+
return this.values.total_count()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public function distinct_len() -> ptr_uint:
|
|
36
|
+
return this.values.len()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
public function capacity() -> ptr_uint:
|
|
40
|
+
return this.values.capacity()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
public function is_empty() -> bool:
|
|
44
|
+
return this.values.is_empty()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
public function count(value: T) -> ptr_uint:
|
|
48
|
+
return this.values.count(value)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public function contains(value: T) -> bool:
|
|
52
|
+
return this.values.contains(value)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public function values() -> linked_map.Keys[T, ptr_uint]:
|
|
56
|
+
return this.values.keys()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
public function entries() -> Entries[T]:
|
|
60
|
+
return Entries[T](values = linked_map_view.SnapshotEntries[T, ptr_uint].create(this.values.values.entries()))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
public function iter() -> Entries[T]:
|
|
64
|
+
return this.entries()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
public function is_subset(other: MultiSet[T]) -> bool:
|
|
68
|
+
if this.total_count() > other.total_count():
|
|
69
|
+
return false
|
|
70
|
+
|
|
71
|
+
for entry in this:
|
|
72
|
+
unsafe:
|
|
73
|
+
let current = read(ptr[T]<-entry.value)
|
|
74
|
+
if entry.count > other.count(current):
|
|
75
|
+
return false
|
|
76
|
+
|
|
77
|
+
return true
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
public function union_with(other: MultiSet[T]) -> MultiSet[T]:
|
|
81
|
+
var result = MultiSet[T].with_capacity(this.distinct_len() + other.distinct_len())
|
|
82
|
+
|
|
83
|
+
for entry in this:
|
|
84
|
+
unsafe:
|
|
85
|
+
let current = read(ptr[T]<-entry.value)
|
|
86
|
+
var count = entry.count
|
|
87
|
+
let other_count = other.count(current)
|
|
88
|
+
if other_count > count:
|
|
89
|
+
count = other_count
|
|
90
|
+
result.add(current, count)
|
|
91
|
+
|
|
92
|
+
for entry in other:
|
|
93
|
+
unsafe:
|
|
94
|
+
let current = read(ptr[T]<-entry.value)
|
|
95
|
+
if not result.contains(current):
|
|
96
|
+
result.add(current, entry.count)
|
|
97
|
+
|
|
98
|
+
return result
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
public function intersection(other: MultiSet[T]) -> MultiSet[T]:
|
|
102
|
+
var result = MultiSet[T].with_capacity(this.distinct_len())
|
|
103
|
+
|
|
104
|
+
for entry in this:
|
|
105
|
+
unsafe:
|
|
106
|
+
let current = read(ptr[T]<-entry.value)
|
|
107
|
+
let other_count = other.count(current)
|
|
108
|
+
if other_count != 0:
|
|
109
|
+
var count = entry.count
|
|
110
|
+
if other_count < count:
|
|
111
|
+
count = other_count
|
|
112
|
+
result.add(current, count)
|
|
113
|
+
|
|
114
|
+
return result
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
public function difference(other: MultiSet[T]) -> MultiSet[T]:
|
|
118
|
+
var result = MultiSet[T].with_capacity(this.distinct_len())
|
|
119
|
+
|
|
120
|
+
for entry in this:
|
|
121
|
+
unsafe:
|
|
122
|
+
let current = read(ptr[T]<-entry.value)
|
|
123
|
+
let other_count = other.count(current)
|
|
124
|
+
if entry.count > other_count:
|
|
125
|
+
result.add(current, entry.count - other_count)
|
|
126
|
+
|
|
127
|
+
return result
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
public function symmetric_difference(other: MultiSet[T]) -> MultiSet[T]:
|
|
131
|
+
var result = MultiSet[T].with_capacity(this.distinct_len() + other.distinct_len())
|
|
132
|
+
|
|
133
|
+
for entry in this:
|
|
134
|
+
unsafe:
|
|
135
|
+
let current = read(ptr[T]<-entry.value)
|
|
136
|
+
let other_count = other.count(current)
|
|
137
|
+
if entry.count != other_count:
|
|
138
|
+
if entry.count > other_count:
|
|
139
|
+
result.add(current, entry.count - other_count)
|
|
140
|
+
else:
|
|
141
|
+
result.add(current, other_count - entry.count)
|
|
142
|
+
|
|
143
|
+
for entry in other:
|
|
144
|
+
unsafe:
|
|
145
|
+
let current = read(ptr[T]<-entry.value)
|
|
146
|
+
if not this.contains(current):
|
|
147
|
+
result.add(current, entry.count)
|
|
148
|
+
|
|
149
|
+
return result
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
public editable function clear() -> void:
|
|
153
|
+
this.values.clear()
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
public editable function release() -> void:
|
|
157
|
+
this.values.release()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
public editable function reserve(min_capacity: ptr_uint) -> void:
|
|
161
|
+
this.values.reserve(min_capacity)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
public editable function insert(value: T) -> ptr_uint:
|
|
165
|
+
return this.values.increment(value)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
public editable function add(value: T, amount: ptr_uint) -> ptr_uint:
|
|
169
|
+
return this.values.add(value, amount)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
public editable function remove_one(value: T) -> bool:
|
|
173
|
+
return this.values.remove_one(value)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
public editable function remove_all(value: T) -> Option[ptr_uint]:
|
|
177
|
+
return this.values.remove(value)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
extending Entries[T]:
|
|
181
|
+
public function iter() -> Entries[T]:
|
|
182
|
+
return this
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
public editable function next() -> bool:
|
|
186
|
+
return this.values.next()
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
public function current() -> Entry[T]:
|
|
190
|
+
let entry = this.values.current()
|
|
191
|
+
return Entry[T](value = entry.key, count = entry.value)
|