generic tree container library

M

Mitchel Haas

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/developers_corner/open_source/tree_container_library/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
 
N

Neil Cerutti

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.
 
B

Ben Pope

Neil said:
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
 
N

Neil Cerutti

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. ;-)
 
M

Mitchel Haas

Neil Cerutti said:
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. ;-)

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
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top