Right after allocators: containers or database connectivity?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 9 15:05:26 PDT 2015


On Tuesday, 9 June 2015 at 18:49:04 UTC, Brad Anderson wrote:
>  We also have map in the form of RedBlackTree. I think you 
> might be able to use RedBlackTree for a set too but I haven't 
> tried it.

You can, but it's a bit of a pain, because you have to keep 
passing it a tuple where the value gets ignored. We really need a 
wrapper around it to make it cleaner.

> I think RedBlackTree isn't a very good name though. It's long 
> and is an implementation detail.

The decision was previously made to name the containers after 
what they actually are rather than what they're used for, and I 
still agree with that decision. However, I do think that we 
should have wrappers and aliases where appropriate (e.g. 
SortedMap could be an alias to RedBlackTree, and SortedSet could 
be a wrapper around RedBlackTree) in order to provide names which 
are based on what you use them for (rather than what they are) as 
folks frequently expectA nd in some cases (like SortedSet), it's 
pretty much necessary unless you have a lot of code duplication, 
since the same data structure is used for multiple container 
types, but the API needs to be slightly different to be truly 
user-friendly.

Regardless, I'm very much in favor of having the core container 
types be named after what they are rather than what they do, 
since I think that that often gets lost when it shouldn't.

- Jonathan M Davis


More information about the Digitalmars-d mailing list