looking for a "tree" class

  • Thread starter Jonathan Wilson
  • Start date
J

Jonathan Wilson

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?
 
P

P.M. Groen

Jonathan said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top