On Thursday 02 September 2010 00:47:23 José Mejuto wrote:
> You must know at which node a new node must be inserted...

If your input data contains a string which always identifies the parent node 
then you can map the string -> "parent node" and find it later for adding a 
child node.

Pseudo code again:

var
  ParentNode, Node: TNode;
  Map: TStringHashMap;
  ParentId, Id: string;
...
  //  get data from somewhere
  ParentId := ...
  Id := ...
  ParentNode := Map[ParentId];
  // This should make Node a root node if ParentNode = nil.
  Node := Tree.AddNode(ParentNode, Id);  // Pseudo syntax.
  Map[Id] := Node;   // Use as parent for following nodes.


If you don't have such ID then you must use recursion.

Juha
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to