English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Creating a tree type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-07 (11:58)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Creating a tree type
On Tue, Feb 08, 2005 at 12:41:37AM +1300, Jonathan Roewen wrote:
> Hi,
> What would be the best approach to creating a tree type such that at
> each node, it has some sort of reference to the parent node? Is this
> an example of when ocaml's OO side would be more useful?
> Basically, I'm creating a UI for my OS; since events will typically
> bubble from leaf nodes up through their ancestors until either the
> event has been handled or have reached the root node, being able to
> reference the parent node efficiently (and easily) is a requirement.
> I've tried a recursive type, but both the defintion and code to make
> use of it is damn ugly and complicated--there just has to be a better
> way to do this sort of thing nicely in ocaml.

I had a similar problem - threading mail using JWZ's threading
algorithm.  It requires you maintain a tree with pointers to parent
and/or root nodes.  You can find the implementation (not by me, but by
Radu Grigore) in
http://sandbox.merjis.com/_file/cocanwiki-1.3.8.tar.gz , in file


Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com