views:

121

answers:

3

I'd like to see some well done PHP code samples of some standard data structures.

Do you know of any code samples of Classes like Linear Linked Lists, Stacks, Queues, Binary Search Trees, etc?

+7  A: 

PHP's Standard PHP Library (SPL) provides a set of standard data structures, including Linked Lists, Stacks, Queues and Heaps.

You can find some code samples of them at Lorenzo Alberton's site.

lkessler
Thanks, this is quite helpful - http://www.php.net/~helly/php/ext/spl/
Peter Ajtai
@Peter also helpful: http://matthewturland.com/2010/05/20/new-spl-features-in-php-5-3/
Gordon
+3  A: 
David
My problem is with the details of PHP. I have no trouble finding many examples of, say C++ implementations, in textbooks and on the net, but it's much harder to find PHP implementations. Turning pseudo code into real code can be done in many ways, and I did it one way, but I'd like to see an example that I know is done well in specifically PHP. ---- In other words I want to see the specifics of the generalities you describe.
Peter Ajtai
+2  A: 

you can get good coding help on data structures in php from here: http://www.codediesel.com/php/ particularly: http://www.codediesel.com/php/linked-list-in-php/ http://www.codediesel.com/algorithms/doubly-linked-list-in-php/

Also other help: http://www.phpclasses.org/package/708-PHP-Linked-List.html http://www.phpclasses.org/browse/file/2369.html

Ankur Mukherjee