471,585 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

looking for a "tree" class

I am looking for a C++ class library that can store data in a tree.
The class library needs to be:
1.Available under a licence like GPL, LGPL or BSD so I can use it in my GPL
program
and 2.Usable on multiple compilers (specificly, Visual C++ on windows and
GCC 3.x MingW on windows. If it works on GCC on Linux, thats even better
but not essential)

What I am storing in this tree is data for a directory tree (its going to
represent the directory tree in a program for working with compressed files
such as .zip or .rar). There will be one root directory node and subnodes
(which might be directory nodes or file nodes). Directory nodes will have
subnodes (unless they are empty of course). File nodes do not have
subnodes. Both directory and file nodes will store a name plus a per-node
structure (which stores different data for files and directories but
provides a way to tell between them)

5 operations will be performed on this tree:
1.Add a new node, either directory or file, given its full path and
per-node data
2.Sort all subnodes of a given node by the name (or better yet, manage
things so that when added, they get sorted automaticly so that node 1 is
the first node alphabeticly and so on)
3.Retrieve a node given its full "path" within the tree
4.Retrieve the subnodes of a given node, given its full "path" within the
tree and a number specifying which subnode to retrieve (for example
retrieve subnode 1 of node abc\def\ghi). This is needed to provide a way to
retrieve all files and folders in a directory to display them in the UI for
my archiver.
5.Walk the tree, deleting the nodes and the per-node structures.

So, it should ideally be able to do these operations efficiantly,
especially no 4

Does a sutable class (or one that could be adapted) already exist?

Jul 22 '05 #1
1 2036
Jonathan Wilson wrote:
I am looking for a C++ class library that can store data in a tree.
The class library needs to be:
1.Available under a licence like GPL, LGPL or BSD so I can use it in my
GPL program
and 2.Usable on multiple compilers (specificly, Visual C++ on windows and
GCC 3.x MingW on windows. If it works on GCC on Linux, thats even better
but not essential)

What I am storing in this tree is data for a directory tree (its going to
represent the directory tree in a program for working with compressed
files such as .zip or .rar). There will be one root directory node and
subnodes (which might be directory nodes or file nodes). Directory nodes
will have subnodes (unless they are empty of course). File nodes do not
have subnodes. Both directory and file nodes will store a name plus a
per-node structure (which stores different data for files and directories
but provides a way to tell between them)

5 operations will be performed on this tree:
1.Add a new node, either directory or file, given its full path and
per-node data
2.Sort all subnodes of a given node by the name (or better yet, manage
things so that when added, they get sorted automaticly so that node 1 is
the first node alphabeticly and so on)
3.Retrieve a node given its full "path" within the tree
4.Retrieve the subnodes of a given node, given its full "path" within the
tree and a number specifying which subnode to retrieve (for example
retrieve subnode 1 of node abc\def\ghi). This is needed to provide a way
to retrieve all files and folders in a directory to display them in the UI
for my archiver.
5.Walk the tree, deleting the nodes and the per-node structures.

So, it should ideally be able to do these operations efficiantly,
especially no 4

Does a sutable class (or one that could be adapted) already exist?


Try a Vector?
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by imani_technology_spam | last post: by
3 posts views Thread by Sarfraz Hooda | last post: by
1 post views Thread by Richard | last post: by
reply views Thread by Tom Bower | last post: by
4 posts views Thread by Bit Byter | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

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.