473,659 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generic tree container library

Hello,

Feeling a need for a generic tree container to supplement the available
containers in the STL,
I've created a generic tree container library (TCL). The library usage is
very much like the containers in the STL, including iterator usage.

Info on the library can be found here..
http://www.visuallandlord.com/develo...y/overview.php
The library and sample code can be downloaded from this site also.
The TCL is open source, and has been thoroughly tested,
but still needs a workout to reveal possible remaining bugs.
Currently it compiles on VC 7 and gcc.

The library is certainly no matching quality to that of the STL or BOOST.
It's purpose is to simply to provide a dependable tree type container
storage.

The library offers three flavors of tree containers:
tree<> : every child within a given parent must be unique

multitree<>: duplicates can exist within a given parent

unique_tree<>: no duplicates can exist within the entire tree structure.
All nodes in the tree must be unique. The unique_tree offers
a handy insert operation of the form insert(parent, child).
In the unique_tree, orphans may be enabled or disabled.
Enabling orphans allows the insertion of nodes in an order
where the parent isn't guarenteed to be present before one
of it's children are inserted.

All three tree classes are derived from a base class, basic_tree<>.

Standard node iterators are provided for iterating children within a parent.
Special "descendent " iterators are avalilable to traverse children and
descendents of nodes:
pre_order_itera tor, post_order_iter ator, and level_order_ite rator.

I'd welcome any feedback, questions, comments, or suggestions regarding the
library.

Thanks,

Mitch Haas
Jan 6 '06 #1
4 4931
On 2006-01-06, Mitchel Haas <mj*@datasoftso lutions.net> wrote:
Hello,

Feeling a need for a generic tree container to supplement the
available containers in the STL, I've created a generic tree
container library (TCL). The library usage is very much like
the containers in the STL, including iterator usage.


How is your tree different from a map? I thought std::map was
pretty much a tree.

--
Neil Cerutti
Jan 6 '06 #2
Neil Cerutti wrote:
On 2006-01-06, Mitchel Haas <mj*@datasoftso lutions.net> wrote:
Hello,

Feeling a need for a generic tree container to supplement the
available containers in the STL, I've created a generic tree
container library (TCL). The library usage is very much like
the containers in the STL, including iterator usage.


How is your tree different from a map? I thought std::map was
pretty much a tree.


std::map is a basic associative container... in that sense it's
"linear". You lookup one type (the value) with another type (the key).
Each key can have one value.

A tree has a single node called the root. Each node can have zero or
more child nodes. A node without children is a leaf node.

They represent completely different concepts.

Often a map is implemented with some kind of a tree, but that's not the
same thing at all.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Jan 6 '06 #3
On 2006-01-06, Ben Pope <be************ *@gmail.com> wrote:
How is your tree different from a map? I thought std::map was
pretty much a tree.


std::map is a basic associative container... in that sense it's
"linear". You lookup one type (the value) with another type
(the key). Each key can have one value.

A tree has a single node called the root. Each node can have
zero or more child nodes. A node without children is a leaf
node.

They represent completely different concepts.

Often a map is implemented with some kind of a tree, but that's
not the same thing at all.


Thanks for your answer. I've had a look at the web page, as well.
I bet if I were a parser/compiler writer I wouldn't have needed
to ask. ;-)

--
Neil Cerutti
Jan 6 '06 #4

"Neil Cerutti" <le*******@emai l.com> wrote in message
news:sl******** *************@F IAD06.norwich.e du...
On 2006-01-06, Ben Pope <be************ *@gmail.com> wrote:
How is your tree different from a map? I thought std::map was
pretty much a tree.


std::map is a basic associative container... in that sense it's
"linear". You lookup one type (the value) with another type
(the key). Each key can have one value.

A tree has a single node called the root. Each node can have
zero or more child nodes. A node without children is a leaf
node.

They represent completely different concepts.

Often a map is implemented with some kind of a tree, but that's
not the same thing at all.


Thanks for your answer. I've had a look at the web page, as well.
I bet if I were a parser/compiler writer I wouldn't have needed
to ask. ;-)

--
Neil Cerutti


Thanks for taking the time to check out the
Tree Container Library (TCL) Neil.
The code used in the library is a little complex,
in that templates are used extensively, but not so complex
that you couldn't understand it once you become familiar with templates.

Also, only a basic understanding of templates is necessary to use
the library. I'd bet that most programmers only have basic understanding
of templates when they start using the STL, which in my opinion
is the best thing since baked bread. After seeing how powerful
and flexible the STL is, it entices programmers to learn more about
templates
and to use teplates in their own code.

If you don't have a solid understanding on using the STL,
I'd recommend getting a copy of "The C++ Standard Library",
and start using the STL in your own code. Once you become
more familiar with the STL, you might be interested in
"C++ Templates" by the same author. But again, you don't
have to know advanced C++ to be able to use the TCL.
Having a good idea on how to use the STL, and a need
to store data in a tree like structure are the only requirements. :)

Mitch Haas
Jan 7 '06 #5

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

Similar topics

49
2870
by: Steven Bethard | last post by:
I promised I'd put together a PEP for a 'generic object' data type for Python 2.5 that allows one to replace __getitem__ style access with dotted-attribute style access (without declaring another class). Any comments would be appreciated! Thanks! Steve ----------------------------------------------------------------------
18
3034
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of a single collections type, I should be proposing a new "namespaces" module instead. Some of my reasons: (1) Namespace is feeling less and less like a collection to me. Even though it's still intended as a data-only structure, the use cases...
5
7690
by: Ravi | last post by:
I recently had to write some code which required me to use a binary search tree (BST) due to running time concerns. I found that there is no BST class in the Standard C++ library. I have been told that other container classes such as set use a balanced BST internally. Is it possible to access this functionality or is the only solution to write a BST class from scratch? -Ravi.
6
7765
by: bear220720 | last post by:
I have a big problem about how to make this C++ program. I was asked to use binary search tree to built a dictionary. This program must have some function, 1. Read a article file and include every word of it into the dictionary. 2. When enter a word, it can make a search and report the word where the search eventually stops. If anyone has this kind of program, please send to me. Thank you!
0
1411
by: Tom Z. | last post by:
Hi All, I'm trying to make an assembly in C# to use as a COM server. I'm building as normal and ruinning regasm at the end. Everything is generally working, except that I'm having a problem hiding some generic implementation base classes from the type library exporter. Here is a code sample: -------------------------------------------------------
1
3579
by: Tom Z. | last post by:
Hi All, I'm trying to make an assembly in C# to use as a COM server. I'm building as normal and ruinning regasm at the end. Everything is generally working, except that I'm having a problem hiding some generic implementation base classes from the type library exporter. Here is a code sample: -------------------------------------------------------
1
2557
by: Christopher | last post by:
I hate to start from scratch as the need for it isn't as great as the work it would take. But, it sure would be nice if I had some data structure that represented a generic tree. I heard using boost's graph library might be an option. Any resources on doing so to implement a tree around? Or any suggestions on an alternative?
1
1625
by: saneman | last post by:
I am writing a container C to be used in a generic library (template library). C are supposed to contain points in either 1,2 or 3 dimension (x), (x,y) or (x,y,z). My first thought was to use a std::vector containing structs with either one, two or three fields (depending on dimension) but are there any better ways to implement C when the code using it should not care what kind of dimension is used?
2
7372
by: cioccolatina | last post by:
Hey guys, is there anyone who could help me..? I have file ExpressionBinaryTree.java : /** class ExpressionBinaryTree * uses a binary tree to represent binary expressions * does not implement BinaryTree - all iterators return String */ package foundations;
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.