On Fri, Dec 24, 2010 at 6:08 PM, Jonathan M Davis
<jmdavisProg@gmx.com> wrote:
On Friday 24 December 2010 00:02:06 Caligo wrote:
> Why are they calling it RedBlackTree? why not Set? C++ std::set is a
> red-black tree as far as I know, but they named it set.
Andrei decided that the containers in Phobos will named after what they actually
are instead of what they're used for. A prime example of this is a red-black
tree. It can be used as a set. Depending on the implementation (I haven't look
at the Phobos one yet), it can also be used as a map (it's used for both set and
map in C++'s STL). But a set could be implemented in many different ways. A red-
black tree is only one of them. It could be implemented with a hash instead. But
that would give it very different performance characteristics.
Phobos is taking the approach that a container is labeled for the data structure
that it is rather than what it's used for. That way it's very clear what it's
performance characteristics are. If you want to use the term Set in your code,
then simply alias RedBlackTree to Set.
- Jonathan M Davis