473,324 Members | 2,531 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,324 software developers and data experts.

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_iterator, post_order_iterator, and level_order_iterator.

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

Thanks,

Mitch Haas
Jan 6 '06 #1
4 4916
On 2006-01-06, Mitchel Haas <mj*@datasoftsolutions.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*@datasoftsolutions.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*******@email.com> wrote in message
news:sl*********************@FIAD06.norwich.edu...
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
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...
18
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...
5
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...
6
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...
0
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...
1
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...
1
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...
1
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...
2
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...
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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.