Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linked list php spl or custom?

Tags:

php

list

I need to use a double linked list using PHP for my script so I dug on the web and found a very good one:

http://www.codediesel.com/algorithms/doubly-linked-list-in-php/

this one made me understand how it works, and how the elements are tied together etc...

Now, PHP has its own set of SPL functions for double linked lists, which makes it very easy but on the other hand, I have to trust what php do and I am also limited to what they have.

Should I use instead the one from PHP? Or should I use this code in the link and in case I want to customize it, can I easily?

like image 636
Pat R Ellery Avatar asked Oct 10 '22 05:10

Pat R Ellery


1 Answers

Use whatever is more appropriate for you, but here are some considerations:

  • PHP SPL code is maintained and community-vetted, code from a random blog is typically not
  • the SplDoublyLinkedList is already there, no extra code to maintain
  • the SplDoublyLinkedList is only there if your PHP version is current
  • you can extend and customize the SplDoublyLinkedList class to your liking
  • the SplDoublyLinkedList may be faster, since it's native code (I guess); benchmark if this an important factor to you
like image 57
deceze Avatar answered Oct 13 '22 12:10

deceze