[英]linked list php spl or custom?
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: 我需要在我的脚本中使用PHP的双链表,所以我在网上挖了一个非常好的:
http://www.codediesel.com/algorithms/doubly-linked-list-in-php/ 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. 现在,PHP有自己的一组SPL函数用于双链表,这使得它非常容易,但另一方面,我必须相信php做什么,我也只限于他们拥有的东西。
Should I use instead the one from PHP? 我应该使用PHP中的那个吗? Or should I use this code in the link and in case I want to customize it, can I easily? 或者我应该在链接中使用此代码,如果我想自定义它,我可以轻松吗?
Use whatever is more appropriate for you, but here are some considerations: 使用更适合您的方法,但这里有一些注意事项:
SplDoublyLinkedList
is already there, no extra code to maintain SplDoublyLinkedList
已经存在,没有额外的代码需要维护 SplDoublyLinkedList
is only there if your PHP version is current SplDoublyLinkedList
仅在您的PHP版本是最新的时才有 extend
and customize the SplDoublyLinkedList
class to your liking 您可以根据自己的喜好extend
和自定义SplDoublyLinkedList
类 SplDoublyLinkedList
may be faster, since it's native code (I guess); SplDoublyLinkedList
可能更快,因为它是本机代码(我猜); benchmark if this an important factor to you 基准,如果这是一个重要的因素给你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.