comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex Mentis" <foo@invalid.invalid>
Subject: Re: Using Red-Black Trees
Date: Tue, 16 Nov 2010 17:17:19 +0000 (UTC)
Date: 2010-11-16T17:17:19+00:00	[thread overview]
Message-ID: <ibueau$aac$1@news.eternal-september.org> (raw)
In-Reply-To: 46306fd9-21dc-40df-88e7-fc7e568399a4@k11g2000vbf.googlegroups.com

Gene wrote:

> On Nov 15, 5:46�pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> > "Alex Mentis" <f...@invalid.invalid> wrote in message
> > 
> > news:ibm2op$m1i$1@news.eternal-september.org...
> > ...
> > 
> > > There's a Red-Black Tree in Ada.Containers?! �Can someone tell me
> > > where to find it in the ARM?
> > 
> > It's not explicit. One of the possible implementations of the
> > ordered sets and maps is to use a Red-Black tree; presumably this
> > is what GNAT's implementation is doing.
> > 
> > � � � � � � � � � � � � � � � � � � Randy.
> 
> Indeed, here is a fragment of the GNAT ordered map implementation via
> rb trees:
> 
>    type Node_Type is limited record
>       Parent  : Node_Access;
>       Left    : Node_Access;
>       Right   : Node_Access;
>       Color   : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
>       Key     : Key_Type;
>       Element : Element_Type;
>    end record;

In the case of the OP, he wanted a specific data structure (rb tree).

Since the ARM doesn't specify exactly how a container must be
implemented, he could go sleuthing through the library code like this
to find out, and in this case he would be lucky enough to determine
that there is, in fact, a container using rb trees, so hooray!

Of course that doesn't guarantee that GNAT will continue to use
red-black trees for these containers in future versions.

It might be nice if, since they're alreay implementing the rb tree for
the ordered sets and maps, GNAT just went ahead and made the library
more visible by documenting it and placing it in the GNAT package
namespace.  I mean, they have a Bubble Sort package in there (Bubble
sort? Really?), so why not some commonly-used tree structures?  I think
we're getting Multi-Way Trees in 2012, but...meh.



  reply	other threads:[~2010-11-16 17:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-13 11:20 Using Red-Black Trees Björn
2010-11-13 12:14 ` Phil Thornley
2010-11-13 13:10 ` Alex Mentis
2010-11-13 13:23   ` Björn
2010-11-13 13:53     ` Alex Mentis
2010-11-13 14:06       ` Björn
2010-11-13 16:31       ` Simon Wright
2010-11-15  8:49   ` Stephane Carrez
2010-11-15 15:32     ` John B. Matthews
2010-11-15 22:46   ` Randy Brukardt
2010-11-16 16:10     ` Gene
2010-11-16 17:17       ` Alex Mentis [this message]
2010-11-16 19:51         ` Randy Brukardt
2010-11-16 21:24           ` Colin Paul Gloster
2010-11-17  2:50           ` Alex Mentis
2010-11-17  5:10             ` Adam Beneschan
2010-11-17 22:59               ` Yannick Duchêne (Hibou57)
2010-11-17 23:15                 ` Vinzent Hoefler
2010-11-17 23:39                   ` Yannick Duchêne (Hibou57)
2010-11-18  0:13                     ` Vinzent Hoefler
2010-11-18  6:27                     ` J-P. Rosen
2010-11-18  7:08                       ` Yannick Duchêne (Hibou57)
2010-11-18 10:47                         ` stefan-lucks
2010-11-18 10:45                           ` Yannick Duchêne (Hibou57)
2010-11-18  9:02                       ` Dmitry A. Kazakov
2010-11-18 12:36                         ` J-P. Rosen
2010-11-18 13:23                           ` Dmitry A. Kazakov
2010-11-17 22:38     ` Yannick Duchêne (Hibou57)
2010-11-13 21:53 ` Jeffrey Carter
2010-11-14  8:20   ` Björn
2010-11-14  8:37     ` Dmitry A. Kazakov
2010-11-13 23:51 ` robin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox