Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Free STL compatible C++ tree container
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Luca Risolia  
View profile  
 More options Aug 8 2012, 1:59 am
Newsgroups: comp.lang.c++
From: Luca Risolia <luca.riso...@studio.unibo.it>
Date: Wed, 08 Aug 2012 07:59:26 +0200
Local: Wed, Aug 8 2012 1:59 am
Subject: Re: Free STL compatible C++ tree container
On 07/08/2012 19:14, Leigh Johnston wrote:

> Hi,

> I present a free to use/modify C++ "tree" container that is so named
> because it can represent a general hierarchical collection of elements
> using a tree-like structure.  Examples of things which use such general
> tree-like structures include file systems, XML elements in an XML
> document or the items in a GUI tree control or menu. The C++ Standard
> Library includes containers which use a binary (2-ary) search tree as
> their underlying data structure (std::set, std::multiset, std::map and
> std::multimap) but their interfaces are designed for accessing the
> elements as an ordered sequence of elements with no hierarchy and do not
> provide direct access to the underlying tree data structure; tree on the
> other hand provides an interface for accessing the (non-fixed-ary) tree
> directly allowing siblings to be iterated, parent elements to be
> determined etc.

Standard containers usually need a comparison function or a functor to
sort the contained elements. The type of the functor is a template
parameter and is std::less<T> by default, which only requires a suitable
operator<() to be defined for T, where T is the type of the elements.

With regard to your tree, not only it does not specify any template
parameter as "comparator", but, if I am not wrong, somewhere it
internally uses operator==() to compare the elements, which turns out to
be a superfluous (and maybe erroneous from the std point of view)
requirement for T, since given two elements e1, e2, then instead of (e1
== e2) you can (or should) write !(e1 < e2) && !(e2 < e1). There are
less evident reasons why the use of operator<() has been preferred to
operator==(), but is another issue.

I think you should also document what kind of guarantees the tree
iterators give to the user after the tree has been modified with one of
its operations.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.