php数组查找时间
我只是想通过梳理一下来找到答案: http://svn.php.net/viewvc/php/php-src/
但我找不到它。在 C++ 中, 被实现为具有 const 键值的平衡二叉搜索树。这很好,您可以获得
O(log n)
搜索、插入、删除等运行时。 O(n)
枚举时间。
我想知道 PHP 数组的底层数据结构。有一些关于 PHP 数组的帖子说“他们做了几乎相同的事情,所以不用担心!”。不是我想要的。是O(1)
(哈希表)还是O(log n)
(平衡二叉树)查找? (例如)
如果有人可以帮助我或向我指出正确的 PHP C 源文件,那就太棒了(尽管有一点解释会很好 - 我真的不擅长 C)。或者,如果您只是对 PHP 数组有很酷的见解,那也很好 - 我正在尝试了解整个底层数据结构。
I just thought I would comb through this to find the answer:
http://svn.php.net/viewvc/php/php-src/
But I couldn't find it. In C++ <map>
is implemented as a balanced binary search tree with const key values. this is nice, you get O(log n)
search, insert, delete, etc runtimes. O(n)
enumeration time.
What I'm wondering is the underlying data structure of PHP arrays. There are a few SO posts on PHP arrays that say "well they do pretty much the same thing, so don't worry about it!". not what I'm after. Is it O(1)
(hash table) or O(log n)
(balanced binary tree) lookup? (for example)
If anyone can help me out or point me to the right PHP C source file, that would be awesome (though a little explanation would be good - I'm really bad at C). Or if you just have cool insights about PHP arrays that's good as well - I'm trying to understand the entire underlying data structure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该实现实际上是某种
HashTable
。-> http://php.net/manual/en/language.types.array。 php
-> PHP 数组是如何在 C 级别实现的?< /a>
The implementation is in fact some sort of a
HashTable
.-> http://php.net/manual/en/language.types.array.php
-> How is the PHP array implemented on the C level?