Map with maintained insertion order
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Mar 23 18:47:31 PDT 2012
On 3/24/12, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> On 3/23/12, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
>> Does someone have a map implementation that maintains the insertion
>> order of the keys?
>
> Here's a sloppy implementation:
I forgot to make opIndex ref, but also the isValue check fails on
structs with alias this, it's better to use is(typeof()) instead of
directly checking the type. The fix would be:
static if (isArray!Value)
{
template isValue(T)
{
enum bool isValue = is(typeof( { Value v; T t; v = t; } )) ||
is(BaseElement!Value == T);
}
}
else
{
template isValue(T) { enum bool isValue = is(typeof( { Value v; T
t; v = t; } )); }
}
More information about the Digitalmars-d-learn
mailing list