Re: [fpc-pascal] TreeView and Nonrecursion
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
Re: [fpc-pascal] TreeView and Nonrecursion
On Wed, Sep 1, 2010 at 6:20 PM, Bihar Anwar bihar_an...@rocketmail.com wrote: On 2 September 2010 3:53:34 AM, Vannus wrote: i probably shouldn't open my mouth, as i don't quite understand the question... however FRED from the game Freespace let you design missions using a treeview. Just to make my question clear, for example, I can fill a TreeView control with particular Registry keys by enumerating registry keys recursively and put them in the TreeView control; then for performance reason, I attempt to use a nonrecursive/iterative approach to enumerate registry keys, but how can I fill the TreeView since a tree is naturally recursive? Is recursion is the only way to achive it? When reading from registry and populating a treeview, a recursive function is the least of your worries regarding performance (or memory, if you're careful). -Flávio ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TreeView and Nonrecursion
On September 2, 2010 5:14:50 PM, Juha Manninen wrote: 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: ... ... If you don't have such ID then you must use recursion. Thanks José and Juha, now I see the light. :-) On September 2, 2010 8:11:53 PM, Flávio Etrusco wrote: When reading from registry and populating a treeview, a recursive function is the least of your worries regarding performance (or memory, if you're careful). I'm a crash-phobia :-). Stack sizes are different among the OS platforms. A superdeep recursion will trigger a stack overflow exception. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Migrating this mailing list to Nabble2
Any administrator that registers this mailing list to Nabble, would you mind upgrading to Nabble2? The request can be put here: http://nabble-support.1.n2.nabble.com/Migrating-forums-from-Nabble1-to-Nabble2-td3791390i200.html -- View this message in context: http://old.nabble.com/Migrating-this-mailing-list-to-Nabble2-tp29611036p29611036.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal