By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,807 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

generic tree container library

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.