www.digitalmars.com         C & C++   DMDScript  

D - what do you think of

reply imr1984 <imr1984_member pathlink.com> writes:
ok i didnt like any of the List classes that i found, so i made my own. what do
you think:

List!(int) myList = new List!(int);

list.append(9);
list.prepend(4);

for(List!(int).Node node = myList.first; node; node = node.next)
{
printf("%u", node());//overloaded opCall
printf("%u", node.t);//not quite as elegant, but required sometimes
}

what do you guys think?
Feb 09 2004
next sibling parent reply "davepermen" <davepermen hotmail.com> writes:
'overload' foreach.. that'll be most fun:D

and opRange should be doable, too, rather simple.. (even for placing into
foreach..)

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:c07ic9$1dje$1 digitaldaemon.com...
 ok i didnt like any of the List classes that i found, so i made my own.
what do
 you think:

 List!(int) myList = new List!(int);

 list.append(9);
 list.prepend(4);

 for(List!(int).Node node = myList.first; node; node = node.next)
 {
 printf("%u", node());//overloaded opCall
 printf("%u", node.t);//not quite as elegant, but required sometimes
 }

 what do you guys think?
Feb 09 2004
parent reply imr1984 <imr1984_member pathlink.com> writes:
is that possible? how do i do that?

In article <c07p50$1p0t$1 digitaldaemon.com>, davepermen says...
'overload' foreach.. that'll be most fun:D

and opRange should be doable, too, rather simple.. (even for placing into
foreach..)

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:c07ic9$1dje$1 digitaldaemon.com...
 ok i didnt like any of the List classes that i found, so i made my own.
what do
 you think:

 List!(int) myList = new List!(int);

 list.append(9);
 list.prepend(4);

 for(List!(int).Node node = myList.first; node; node = node.next)
 {
 printf("%u", node());//overloaded opCall
 printf("%u", node.t);//not quite as elegant, but required sometimes
 }

 what do you guys think?
Feb 09 2004
parent "davepermen" <davepermen hotmail.com> writes:
its all in the manuals..

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:c085vu$2dtc$1 digitaldaemon.com...
 is that possible? how do i do that?

 In article <c07p50$1p0t$1 digitaldaemon.com>, davepermen says...
'overload' foreach.. that'll be most fun:D

and opRange should be doable, too, rather simple.. (even for placing into
foreach..)

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:c07ic9$1dje$1 digitaldaemon.com...
 ok i didnt like any of the List classes that i found, so i made my own.
what do
 you think:

 List!(int) myList = new List!(int);

 list.append(9);
 list.prepend(4);

 for(List!(int).Node node = myList.first; node; node = node.next)
 {
 printf("%u", node());//overloaded opCall
 printf("%u", node.t);//not quite as elegant, but required sometimes
 }

 what do you guys think?
Feb 09 2004
prev sibling parent Sam McCall <tunah.d tunah.net> writes:
imr1984 wrote:

 ok i didnt like any of the List classes that i found, so i made my own. what do
 you think:
 
 List!(int) myList = new List!(int);
 
 list.append(9);
 list.prepend(4);
 
 for(List!(int).Node node = myList.first; node; node = node.next)
 {
 printf("%u", node());//overloaded opCall
 printf("%u", node.t);//not quite as elegant, but required sometimes
 }
 
 what do you guys think?
 
 
Nice! I still think List should be an interface a la Java though, with linked and array based implementations. Implementing foreach and indexing would be nice. Sam
Feb 09 2004