Re: Rob, How?

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu