473,238 Members | 1,971 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,238 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 2124
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: imani_technology_spam | last post by:
We need to present hierarchical data on a web page, the same way the tree view shows files in Windows Explorer. Here's the catch: that tree view needs to be bound to a SQL Server database. How...
3
by: Sarfraz Hooda | last post by:
Hi, I am wondering if there is already a Tree class available in the framework which i can use in my application? If not then is there a site on the net where i can get the sample...
11
by: Joseph Turian | last post by:
Fellow hackers, I have a class BuildNode that inherits from class Node. Similarly, I have a class BuildTree that inherits from class Tree. Tree includes a member variable: vector<Node>...
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
1
by: Richard | last post by:
http://dynamicdrive.com/dynamicindex1/switchmenu.htm I want to add a second level menu item to the existing design. Currently only one level is possible. Item 1 ......link ......link item 2...
5
by: Kevin R | last post by:
I'm trying to update a sql database. It's modified Oledb code from an example that did work with an access database. How can I tweak my code to make it work? Thanks in advance. Kevin...
0
by: Tom Bower | last post by:
In the Windows Task Manager if I select a Process and right-click, I can choose to "End Process" or "End Process Tree." Is there a VB equivalent for "End Process Tree" if you have a handle to a...
2
by: Bart Kastermans | last post by:
Summary: can't verify big O claim, how to properly time this? On Jun 15, 2:34 pm, "Terry Reedy" <tjre...@udel.eduwrote: Thanks for the idea. I would expect the separation to lead to somewhat...
4
by: Bit Byter | last post by:
I want to write a (singleton) container for instances of my class templates, however, I am not too sure on how to: 1). Store the instances 2). How to write the acccesor method (instance()) to...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.