Re: Question about hashtables implementation
| From: | Amaury Bouchard | Date: | Sun, 02 Sep 2012 19:30:47 +0000 |
| Subject: | Re: Question about hashtables implementation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62680@lists.php.net to get a copy of this message | ||
2012/9/2 Sherif Ramadan <theanomaly.is@gmail.com>
> To clarify, this particular functionality you're using as an example
> "array_unshift" really isn't specific to the internal implementation
> of hashtables in PHP. That is to say that this side-effect you're
> describing is specific to that function and not necessarily
> hashtables' internal implementation.
>
OK, thanks for the information. It explains why I didn't find anything in
the HashTable structure (unlike iterator pointer or the next free key).
Essentially, array_unshift() just rebuilds the array. From
> http://php.net/array-unshift "All numerical array keys
> will be
> modified to start counting from zero while literal keys won't be
> touched"
>
You're right; I hadn't noticed that.
Side effect: add values at the beginning of an array could be very
time-consuming, according to its size.
If you're interested in a more detailed explanation of the
> implementation of PHP's Array type you might find this article by
> Nikic useful:
> "l%ëL
> µíò¤â
Thanks again for this link. I have the book of Sara (huge piece of work,
btw), and I found some good documentation. But more information wouldn't
hurt! :-)