January 20, 2004
Sorry for double post, I pressed Send too fast. :-(


In article <buk20m$lf9$1@digitaldaemon.com>, Stephan Wienczny says...

Shouldn't line 2 be before line 1?

Check this by InsertingAfter, and then try to backstep, this should demonstrate the wrong value in iter.next.prev.

void InsertAfter(Node iter, T value)
{
if (!iter) throw new IlleagalIterator("Given iterator does not exists");

Node elem = new Node(value, iter, iter.next);
m_size++;
iter.next = elem;        // line 1
iter.next.prev = elem;   // line 2 should be before line 1
if (elem.next) elem.next.prev = elem;
}

Oh, and obviously the same for InsertBefore.


January 21, 2004
Georg Wrede wrote:
> Sorry for double post, I pressed Send too fast. :-(
> 
> 
> In article <buk20m$lf9$1@digitaldaemon.com>, Stephan Wienczny says...
> 
> Shouldn't line 2 be before line 1?
> 
> Check this by InsertingAfter, and then try to backstep,
> this should demonstrate the wrong value in iter.next.prev.
> 
> void InsertAfter(Node iter, T value)
> {
> if (!iter) throw new IlleagalIterator("Given iterator does not exists");
> 
> Node elem = new Node(value, iter, iter.next);
> m_size++;
> iter.next = elem;        // line 1
> iter.next.prev = elem;   // line 2 should be before line 1
> if (elem.next) elem.next.prev = elem;
> }
> 
> Oh, and obviously the same for InsertBefore.
> 
> 
You are right. I wrote those functions but actually never used them...

January 21, 2004
In article <bumat3$17ah$1@digitaldaemon.com>, Stephan Wienczny says...
>
>Georg Wrede wrote:
>> Sorry for double post, I pressed Send too fast. :-(
>> 
>> 
>> In article <buk20m$lf9$1@digitaldaemon.com>, Stephan Wienczny says...
>> 
>> Shouldn't line 2 be before line 1?
>> 
>> Check this by InsertingAfter, and then try to backstep, this should demonstrate the wrong value in iter.next.prev.
>> 
>> void InsertAfter(Node iter, T value)
>> {
>> if (!iter) throw new IlleagalIterator("Given iterator does not exists");
>> 
>> Node elem = new Node(value, iter, iter.next);
>> m_size++;
>> iter.next = elem;        // line 1
>> iter.next.prev = elem;   // line 2 should be before line 1
>> if (elem.next) elem.next.prev = elem;
>> }
>> 
>> Oh, and obviously the same for InsertBefore.
>> 
>> 
>You are right. I wrote those functions but actually never used them...

On second glance, the code still probably works, even with that mistake! The reason being that the if-line performs actually the same function as line 2, and does it right!

Hmm, this uncovers one problem with unit tests. If one sees a unit with lots of unit test code, one tends to intuitively believe that the code is kind of robust and tested.

I wonder how M$'s unit tests would look like. :-)


January 21, 2004
Georg Wrede wrote:
>Georg Wrede wrote:
> 
> On second glance, the code still probably works, even with that
> mistake! The reason being that the if-line performs actually the
> same function as line 2, and does it right!
> 
> Hmm, this uncovers one problem with unit tests. If one sees a
> unit with lots of unit test code, one tends to intuitively believe that the code is kind of robust and tested. 
> 
> I wonder how M$'s unit tests would look like. :-)
> 
> 

The code works if there iter has a next element! It there is none it segfaults.

The correct version should be:

void InsertAfter(Node iter, T value)
{
if (!iter) throw new IlleagalIterator("Given iterator does not exist");
Node elem = new Node(value, iter, iter.next);  // [iter]<-[elem]->[]
m_size++;
iter.next = elem;   // [iter]->[elem]
if (elem.next) elem.next.prev = elem; // elem<-[]
}

You should take a deeper look at the unittest:
This unittest does not even compile using a current version dmd!
Walter forbid to overload the '++' operator for non basic types...
Then look what is tested. I checked only the basics.

I think M$ uses this way for unit testing:
They write a unit. To test it they write another program using it. Then they sell this program containing the unit. If there are no complains about the program the unit should work ;)

Stephan




January 22, 2004
So is someone going to post a link / post the updated version ?

In article <bumhcm$1i4h$1@digitaldaemon.com>, Stephan Wienczny says...
>
>Georg Wrede wrote:
>>Georg Wrede wrote:
>> 
>> On second glance, the code still probably works, even with that mistake! The reason being that the if-line performs actually the same function as line 2, and does it right!
>> 
>> Hmm, this uncovers one problem with unit tests. If one sees a unit with lots of unit test code, one tends to intuitively believe that the code is kind of robust and tested.
>> 
>> I wonder how M$'s unit tests would look like. :-)
>> 
>> 
>
>The code works if there iter has a next element! It there is none it segfaults.
>
>The correct version should be:
>
>void InsertAfter(Node iter, T value)
>{
>if (!iter) throw new IlleagalIterator("Given iterator does not exist");
>Node elem = new Node(value, iter, iter.next);  // [iter]<-[elem]->[]
>m_size++;
>iter.next = elem;   // [iter]->[elem]
>if (elem.next) elem.next.prev = elem; // elem<-[]
>}
>
>You should take a deeper look at the unittest:
>This unittest does not even compile using a current version dmd!
>Walter forbid to overload the '++' operator for non basic types...
>Then look what is tested. I checked only the basics.
>
>I think M$ uses this way for unit testing:
>They write a unit. To test it they write another program using it. Then
>they sell this program containing the unit. If there are no complains
>about the program the unit should work ;)
>
>Stephan
>
>
>
>


January 22, 2004
imr1984 wrote:
> So is someone going to post a link / post the updated version ?
> 

You can get it from:

http://d.wienczny.de



January 22, 2004
cheers. Are you going to get that site put on the links page ?

In article <bupb1u$1tp$1@digitaldaemon.com>, Stephan Wienczny says...
>
>imr1984 wrote:
>> So is someone going to post a link / post the updated version ?
>> 
>
>You can get it from:
>
>http://d.wienczny.de
>
>
>


January 22, 2004
imr1984 wrote:
> cheers. Are you going to get that site put on the links page ?
> 
> In article <bupb1u$1tp$1@digitaldaemon.com>, Stephan Wienczny says...
> 
>>imr1984 wrote:
>>
>>>So is someone going to post a link / post the updated version ?
>>>
>>
>>You can get it from:
>>
>>http://d.wienczny.de
>>
>>
>>
> 
> 
> 

Maybe Walter reads this!?!?

January 23, 2004
Stephan Wienczny wrote:

> imr1984 wrote:
>
>> cheers. Are you going to get that site put on the links page ?
>>
>> In article <bupb1u$1tp$1@digitaldaemon.com>, Stephan Wienczny says...
>>
>>> imr1984 wrote:
>>>
>>>> So is someone going to post a link / post the updated version ?
>>>>
>>>
>>> You can get it from:
>>>
>>> http://d.wienczny.de
>>>
>>>
>>>
>>
>>
>>
>
> Maybe Walter reads this!?!?
>
You can put it on the Wiki yourself:
http://f17.aaacafe.ne.jp/%7Elabamba/
http://www.prowiki.org/wiki4d/wiki.cgi?FrontPage

-- 
-Anderson: http://badmama.com.au/~anderson/
January 29, 2004
In article <bupb1u$1tp$1@digitaldaemon.com>, Stephan Wienczny says...
>
>imr1984 wrote:
>> So is someone going to post a link / post the updated version ?
>> 
>
>You can get it from:
>
>http://d.wienczny.de
>
>
>

sorry to bring this old subject up again, but id just though id point out that the class doesnt follow the D naming convections. Sorry if im being fussy, its quite nice otherwise.

By the way, is there any chance well see generic linked lists being built into the D language?