Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] Creating a tree type
On Mon, 7 Feb 2005 16:01:01 +0000, Jon Harrop <jon@jdh30.plus.com> wrote:
> On Monday 07 February 2005 11:41, Jonathan Roewen wrote:
> > 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...
> 
> Adding references to the parent of each node in a tree makes the data
> structure a graph and not a tree.
> 
> This can be implemented in several ways. However, I strongly recommend that
> you do not do this to begin with, for several reasons:

Okay, so I realised I could just use a Stack to track a walk through the tree...

A couple more questions though:

1. For the Stack, when I put something in it, is it copied or what?
How does that work?

2. How do I make my tree like a hashtable, i.e. modifications are done
in-place? Some sort of nested Map or something? Using lists to build
up the tree would cause pain when wanting to modify it. It would also
seem inefficient to use lists for this particular use case.

Regards,

Jonathan.