If you’re interested, I created a data structure for scored prefix completion, paper available here:
Graphical explanation:
https://validark.github.io/DynSDT/demo/
Implementations in Zig and a few other languages:
Didn’t 100% polish the Zig version because I didn’t totally commit to what use case to optimize for and it was my first Zig project. I’ll probably revisit the project once we get this issue solved: introduce labeled continue syntax inside a switch expression · Issue #8220 · ziglang/zig · GitHub