How associative arrays work internally
Вставка
- Опубліковано 28 вер 2024
- 👨💻 Learn Test-Driven Development with Laravel!
tddwithlaravel...
Sign up to 30 Days of Laravel 👉🏻 30daysoflarave...
👨💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis:
subscribe.mate...
🎉 Party up:
/ mateusjatenee
/ mateusjatenee
/ mateusguimaraes
Thanks for watching!
This was a great video. Just what I needed to solve a problem I've been having. Thanks Mateus!
Glad you liked it!
Thanks for this Mateus, so well explained
Glad it was helpful!
This is more about data structures than the PHP internals.
But either way, the DSA is needed to be understood to Unterstand the PHP internal of it.
Cool walkthrough.
Thanks!
love that in depth content thanks 🙏
Glad you enjoy it!
great video. like always
I appreciate that
3:58, why would the hash produce the same index?
Because hashes are not necessarily collision-free, specially when they’re a limited set.
For example - the example I use later in the video: hash = (product of the bytes) % table_size.
The number of distinct hashes available is table_size. If you add table_size + 1 elements, you’re guaranteed to have at least *1* collision.
In the example where the hash is based on the bytes, foo and oof would generate the same hash, because their product is the same.
Does that make sense?
The hash produces an integer that IS USED as an index. Within a limited memory space you’re bound to have collisions.