5 ms·
FWIW, there's an implementation of a doubly linked list in the SPL. http://www.php.net/manual/en/class.spldoublylinkedlist.php http://www.php.net/manual/en/cla
by Scriptor 16y ago
FWIW, there's an implementation of a doubly linked list in the SPL.
http://www.php.net/manual/en/class.spldoublylinkedlist.php http://www.php.net/manual/en/class.spldoublylinkedlist.php
LispHP seems to use ArrayObject, though I'm not really sure how its performance is (googling indicates iteration is slow).
- arghnoname 16y agoIs that written in C? Implementing a linked list in PHP isn't difficult, but I'd imagine memory use would be prohibitively expensive. If that is not written as a C extension, and perhaps even if it is, presumably you'd get a big speedup if you implemented a list with common lisp operations in mind as an extension for a project like this. It could fall back to a PHP implementation if the extension is not/can not be loaded. It's kind of moot because if speed were a huge concern, this might not be used in the first place, but just it would be interesting to see how far such a thing could be taken.
- jonursenbach 16y agoAll SPL classes/methods are written in PHP. They're essentially PEAR classes that just come preinstalled.
- Scriptor 16y agoIncorrect. The SPL is entirely implemented in C.
- jonursenbach 16y agoHuh interesting.
- salathe 16y agos/entirely/also/
- arghnoname 16y agoAh, that's why my memory was fuzzy. I downloaded PHP and as of 5.3, the SPL does come with a double linked list, and a userland and C implementation are both in the tarball. Why is there a PHP version also?
- jacquesm 16y agoMaybe as a fallback in case the extension isn't loaded ?