Is there a sorted map?

stunaep via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 13 03:06:24 PDT 2016


On Sunday, 13 March 2016 at 08:33:43 UTC, Jonathan M Davis wrote:
> On Sunday, March 13, 2016 02:35:27 stunaep via 
> Digitalmars-d-learn wrote:
>> [...]
>
> The closest that we have in Phobos at the moment is 
> RedBlackTree in std.container. Its API is geared towards sets, 
> not maps, but you can get it to work as a map if you define the 
> comparison functions appropriately. Red-black trees are 
> typically used for both sets and maps, so using RedBlackTree in 
> that manner is pretty normal from an implementation 
> perspective, but there's no question that what we really need 
> is a wrapper around it that provides a map API, since it's not 
> terribly user-friendly to use the set API for a map, much as it 
> works.
>
> [...]

Wow, thanks!


More information about the Digitalmars-d-learn mailing list