www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is this a good tree?

reply Vladimirs Nordholm <v vladde.net> writes:
Hello.

I want to create a tree which maps sequences of numbers to data. 
ex:
- [1, 2]    -> 1
- [1, 3, 1] -> 2
- [1, 3, 2] -> 3

I have no prior knowledge of what makes a good tree, and I am 
unsure if what I've got is good. I mean it works, but if anyone 
with more knowledge of trees or D-lang would mind giving some 
feedback I would be more than happy.

I've made a scaled-down, "in essence", runnable example of what I 
have here: https://run.dlang.io/is/JI8T2T

For more context, my actual code (with extra boilerplate + 
project specific things) can be found here: 
https://github.com/vladdeSV/scone/blob/develop/source/scone/os/posix/input/input_tree.d

Once again, any feedback is greatly appreciated.
Jun 02 2020
parent reply Q. Schroll <qs.il.paperinik gmail.com> writes:
On Tuesday, 2 June 2020 at 11:44:10 UTC, Vladimirs Nordholm wrote:
 Hello.

 I want to create a tree which maps sequences of numbers to 
 data. ex:
 - [1, 2]    -> 1
 - [1, 3, 1] -> 2
 - [1, 3, 2] -> 3

 I have no prior knowledge of what makes a good tree, and I am 
 unsure if what I've got is good. I mean it works, but if anyone 
 with more knowledge of trees or D-lang would mind giving some 
 feedback I would be more than happy.

 I've made a scaled-down, "in essence", runnable example of what 
 I have here: https://run.dlang.io/is/JI8T2T

 For more context, my actual code (with extra boilerplate + 
 project specific things) can be found here: 
 https://github.com/vladdeSV/scone/blob/develop/source/scone/os/posix/input/input_tree.d

 Once again, any feedback is greatly appreciated.
You might want to check out this: https://en.wikipedia.org/wiki/Trie Possibly, that's exactly what you're looking for.
Jun 02 2020
parent Vladimirs Nordholm <v vladde.net> writes:
On Tuesday, 2 June 2020 at 12:34:53 UTC, Q. Schroll wrote:
 On Tuesday, 2 June 2020 at 11:44:10 UTC, Vladimirs Nordholm 
 wrote:
 [...]
You might want to check out this: https://en.wikipedia.org/wiki/Trie Possibly, that's exactly what you're looking for.
Thank you! I believe this is exactly what I need ;)
Jun 02 2020