U++ framework
Do not panic. Ask here before giving up.

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: 14291
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: Mon Sep 14 08:58:36 GMT+2 2026

Total time taken to generate the page: 0.00696 seconds