On 25/11/05, Mickael Faivre-Macon <faivrem / gmail.com> wrote:
> Hi Robert,
>
> Thanks for your reply.
>
> What would be the reference class for Ruby ?
> For example it is said tat REXML is the reference for managing XML.
> Is there such a librairy for trees ?
>
> A lot of lib in the RAA are too specialized (binary trees, avl,
> redblack trees, etc)
> I am searching for a general tree class.
>
> Mickael.
>
>
> On 11/25/05, Robert Klemme <bob.news / gmx.net> wrote:
> > Mickael Faivre-Macon wrote:
> > > Hi,
> > >
> > > Is there a tree class in the language or a good lib out there ?
> > > Thanks for your suggestions.
> >
> > http://raa.ruby-lang.org/search.rhtml?search=tree
> >
> > Kind regards
> >
> >     robert
> >
> >
> >
>

The question should be what you want to do with your tree. You should
pick a datastructure suitable for your problem, there is no tree per
se. It depends on which pointers you need and which structure your
tree should have.

If you just want nodes with children try this "reference implementation"

---
class Node
  attr_reader :children

  def initialize
    @children = []
  end
end
---

which may or may not suit your needs.

Cheers,

Brian

--
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/