Firstly, apologies if this is not the correct place to ask such a
question - I was directed here from a forum.
I recently discovered the datastructures found in the Standard PHP
Library. I noticed that SplStack is implemented using a doubly-linked
list and wondered why. Given that a stack is LIFO store and the only
operations really needed are push and pop, why would next and previous
pointers be required on each item? There's no requirement to allow
iteration over a stack.
It would seem to me that a stack should require a linear linked list and
a pointer to the top of the stack - which would have roughly half the
memory overhead of a doubly-linked list (half the number of pointers).
Do i just have no idea what i'm talking about or have i missed something
obvious?
Thanks in advance,
Ben
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php