Re: Rob, How?
- Posted by Robert Craig <rds at ATTCANADA.NET> Aug 18, 2000
- 481 views
Ian writes: > Another question i have, for my own programming purposes, > how did you implement the sequence idea in C/C++? > i've attempted my own linked list class and a template class > but none are stable enough to implement in a large program. If you look at the sieve C code that I released yesterday you'll get some idea. I originally (pre-1.0) implemented sequences as linked lists. The performance on random subscript operations was pretty poor, so I made them doubly-linked, and I kept a pointer in each sequence to the most recently referenced element. That helped a lot when you looped over a consecutive series of elements (as you often do). If you accessed x[25] followed by x[26], x[27], ... you could quickly locate the next element without starting at the beginning of the list and stepping through 25 elements. Eventually though I just implemented sequences as arrays. That made subscripting really fast, but things like append() became slower and had to be dealt with in a smarter way. More importantly, getting rid of all those links saved a ton of memory. Euphoria is implemented in plain C. I don't use any C++ features. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com