std.container: RedBlackTree questions
Ivan Kazmenko
gassa at mail.ru
Fri Aug 2 07:46:04 PDT 2013
On Thursday, 1 August 2013 at 14:51:14 UTC, monarch_dodra wrote:
> On Thursday, 1 August 2013 at 12:27:51 UTC, Ivan Kazmenko wrote:
>> I am trying to use RedBlackTree container to maintain a set of
>> Elems, Elem being a non-trivial struct. The problem is that I
>> find the container hard to use.
>> <...>
>> So, now I have a working program unless I want to run a
>> unittest, in which case, it does not compile. I wonder what's
>> so wrong with the examples 3 and 4, and how do I get them to
>> compile regardless of compiler options?
>>
>> On a relevant note, I find the unittests of RedBlackTree a bit
>> excessive even when they compile successfully. They seem to
>> test the integrity of the whole tree every time a tree
>> operation takes place, and that makes the unittests version of
>> my local code run too slowly. Is there a way to turn
>> unittests on only for user code and turn them off for the
>> standard library?
>>
>> Ivan Kazmenko.
>
> N°4 is clearly a bug in the implementation.
> N°3, I'm not sure what is going on with the "put" bugs, but it
> seems to be fixed in head.
>
> In both case, one of the problems is that
> "redBlackTree!less_data" seems to be taking the wrong overload,
> which explains some of your problems. I'd use an explicit:
>
> tree = new RedBlackTree!(int, less_data)(); //No surprises
>
> In any case, yes, it is buggy.
Thank you for the answer. The explicit way indeed helps to
compile Example 3 (without unittests) using the official DMD
2.063.2 release.
So I should create an issue describing my problems with example 4
but not example 3? And perhaps a separate one for the slowdown
with unittests turned on. Right?
What about examples 1 and/or 2, can they be patched to work, too?
And if not, why?
More information about the Digitalmars-d-learn
mailing list