Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » NEW: Tree<T> container
Re: NEW: Tree<T> container [message #27995 is a reply to message #27732] Fri, 13 August 2010 09:28 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
Ah, the "tree container" problem.

I have to say I have spent quite some time trying to figure this one out.

My current position is that it is not worth the effort. In almost all cases, you need some specialized handling of trees and for those, existing containers are quite fine.

So now I usually use some sort of Array or ArrayMap to represent trees.

I guess the most simple method is something like:

struct Node {
int parent;
....
};

Array<Node> tree;

where parent is either directly index of parent node in 'tree', or some mode sophisticated thing, like database id, in that case

ArrayMap<int, Node> tree;

is perhaps better. Of course, at this point get varied by actual requirements.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DUMP for Maps [FEATURE REQUEST]
Next Topic: PROPOSAL: small / usefull Stream iface extension
Goto Forum:
  


Current Time: Wed Jun 18 09:08:13 CEST 2025

Total time taken to generate the page: 0.09536 seconds