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.