list21.backwards

simon.hodson at hssnet.com simon.hodson at hssnet.com
Wed Jun 21 07:49:29 PDT 2006


Thanks Chris,

I've found another similar assert issue where a filter is applied against an
empty list and then the list be sorted backwards: -

module people;
private import std.stdio;
private import list;

class Person
{
mixin List; // Turn the Person class into a linked list.

char[] name,tname;
ubyte age;

this(char[] name, ubyte age){this.name = name;this.age = age;}
}

int main()
{
Person.ListHead people,others;

writefln("-start filter-");
others.filter(
delegate bool(Person f)
{
if(f.name is null)
{
others.remove(f);
}
return true;
}
);
writefln("-end filter-");

foreach(Person p; others.each.backwards)
{
writefln("Person %s is %d years old", p.name, p.age);
}
return 0;
}

produces: -

C:\list21>testing6
-start filter-
Error: AssertError Failure list.d(648)


Regards

Simon


In article <op.tbhrcyuppo9bzi at moe>, Chris Miller says...
>
>On Tue, 20 Jun 2006 12:36:20 -0400, <simon.hodson at hssnet.com> wrote:
>> So iterating over a list is OK provided you don't try to reverse it. I'm
>> guessing this is an error in the library but not sure how to fix it.   
>> Anyone got
>> an idea?
>>
>> Simon
>
>A fixed version is uploaded to http://www.dprogramming.com/list.php -  
>thanks for letting me know about this. It was only an issue in a contract  
>(debug only).





More information about the Digitalmars-d-learn mailing list