Fast way to append to an SList

Fernando Carvajal fernandocarvajal at mailinator.com
Fri Jan 13 03:34:39 PST 2012


I need a fast way to append to an SList. I was thinking of using insertAfter()
and keep track of a range that points to the end of the list but, after
appending an item, how would you get the new range to the end?

This is what I had planned:

List!int list;
Range end = list[];

list.insertAfter(end, 42);
end = // How to get the new end?

list.insertAfter(end, 21);
...

So, how would you get the end of a SList without traversing it from the start?

Thanks



More information about the Digitalmars-d-learn mailing list