From: Jesse G. <je...@wi...> - 2004-09-11 22:01:52
|
Nicolas Cannasse wrote: >> On the subject of Dllist.enum... I noticed that the count () >> function always computes the length of the remaining nodes >> by traversing the list. It would be more efficient to do >> this, I think: >> >> 1) The first time count () is called, compute the length >> and store it "in the enum". >> >> 2) Subsequent calls to count () just return the computed >> length. >> >> 2) Every time next () is called, decrese the number of >> remaining elements by 1 (if the number hasn't been set, >> you don't need to do anything). >> >> This would only incur minimal overhead for next () and for >> any code the uses count () it basically reduces count () >> to O(1) averaged over all the elements. > > This is actually the implementation of List.enum. > Jesse you can have a look at it to implement it. OK. I'll see what I can do. -- Jesse Guardiani, Systems Administrator WingNET Internet Services, P.O. Box 2605 // Cleveland, TN 37320-2605 423-559-LINK (v) 423-559-5145 (f) http://www.wingnet.net |