2009/2/18 Aldric Giacomoni <"aldric[removeme]"@trevoke.net>:
> I know I could just use rubytree, which looks quite nice, but I'd like
> to see what you guys would do about creating a tree and linking the
> nodes together.
> In C++ we'd just make pointers, so how would we do the equivalent in Ruby?
>

It depends .. if you are just making trees for the sake of trees (or
measuring something on them) you can go with the simple Node object or
an array structure that implements the nodes.

On the other hand you may use a hash and forget about trees completely
if your data is one flat value, and use multiple layers of hashes if
you have something like vectors or strings where you can split the
value into multiple parts naturally.

ie {1=>{1=>{0=>[1, 1, 0]}, 2=>{3=>[1, 2, 3]}}, 2=>{3=>{4=>[2, 3, 4]}}}

Thanks

Michal