473,322 Members | 1,398 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,322 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 2130
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.