473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

stl data structure to represent a tree

I am looking for a data structure or perhaps a container that I can use
to represent linux-like file system (each node in the tree containes
needed fields, i.e. permissions, d/f, etc: for this I am thing of
mapping node to a structure.. any commetns about this).
Any suggestions (other then implementing my own tree)?
Thanks

Sep 18 '05 #1
4 2519
Daw
Maybe you can make a structure like

struct FS {
// permissions, d/f etc.
};

and then use some container like

std::vector<FS> nodes;

Sep 18 '05 #2
I am thinking to have something like this:

struct Entry{

union {
std::stringBuffer info; // dont remembe the exact equivalent for
sting buffer :)
std::vector<Entry>;
}type;
};
what is the best way to distinguesh the current content of the union?

thx

Sep 18 '05 #3
I forgot that unions have some issues with nontrivial ctors...

so here my another attempt
struct Entry{

all flags shared by directory and files

};
struct FileEntry:Entry{

string buffer

};

struct DirEntry:Entry{

vector<Entry> ve;

};

I am thing along this lines..
I am also considering forwarding approach... any pro/cons?

Sep 18 '05 #4
puzzlecracker wrote:
I forgot that unions have some issues with nontrivial ctors...

so here my another attempt
struct Entry{

all flags shared by directory and files

};
struct FileEntry:Entry{

string buffer

};

struct DirEntry:Entry{

vector<Entry> ve;

};

I am thing along this lines..
I am also considering forwarding approach... any pro/cons?


Your code above suffers from slicing, you need pointers (or possible
smart pointers).

struct DirEntry:Entry{

vector<Entry*> ve;

};

You need to read up on polymorphism, which is what you are heading
towards above.

I'm not sure what you mean by a forwarding approach.

john
Sep 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: vivek khurana | last post by:
Hi! all i am a new member on this list. I have to implement tree data structure using python. How it can be done in python. Is there an existing data structure which can be used as tree? I have...
0
by: clintonG | last post by:
I need a tree control and seek referrals to your preferred solution(s) that will support mapping XML data structures to the tree. <%= Clinton Gallagher
4
by: Marek Mänd | last post by:
var criterions = { subconds:{ tree: } } // MUSIC , {condID:17, strrep:'Music', subconds:{ tree:
4
by: Sasha | last post by:
Hi everyone, I would like to hear your opinions about a design solution I am contemplating. The problem I am following: Write an editor for a data structure that is recursive in nature. In...
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
6
by: Travis | last post by:
Is there a community accepted best way to store a menu tree for an interface in a data structure. Ideally I would like something that searches fast so given a menu structure like this File / ...
4
by: Alexander Adam | last post by:
Hello folks, I got a few question on some basic data structure stuff. Sorry if those questions might sound too easy or such but after googling a lot I didn't find a real answer to all those...
3
by: Rahul | last post by:
Hi Everyone, I have the following set of data and currently i'm using an array of structures to represent the same, i would like to know if any other data structure would be suitable. name...
4
by: sharan | last post by:
Hello Friends I have a problem in Data Structure (In C) i want to implement a General tree having three child nodes of each parent node ...please send me any simple Example( code) by which i can...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.