3 ms·
Tangential, but is there a name for a Trie that isn't for string searching/matching? I've had a need for this in the past but each node needed to store a non-ch
by crescentfresh 8y ago
Tangential, but is there a name for a Trie that isn't for string searching/matching? I've had a need for this in the past but each node needed to store a non-character value. This was to facilitate a sort-of path finding where the input was matched against a known set of paths.
Every library I looked at had implementations revolving around nodes that stored chars (you know, for auto-complete scenarios) but nowhere in the definition of a Trie is it bound to such an implementation (so I thought).
- mattnewton 8y agoI think that is just the common use case. It shouldn’t be too hard to roll your own here, it’s just a set of tree traversal functions.
- crescentfresh 8y agoOh I did, was just surprised every formal language had one tied to string searching/matching, including this demo.
- superlopuh 8y agoHere's mine: https://github.com/superlopuh/SuperTrie https://github.com/superlopuh/SuperTrie I've implemented at least 5 different generic Tries since this one. The idea is almost always the same, but different tradeoffs can require different implementations. While I don't recommend that you use this version, the contents of [1] should give you all the inspiration you need to roll your own. [1] https://github.com/superlopuh/SuperTrie/blob/master/SuperTrie/STNode.swift https://github.com/superlopuh/SuperTrie/blob/master/SuperTri...