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!

КОМЕНТАРІ • 13

  • @swancompany_inc
    @swancompany_inc 4 місяці тому

    This was a great video. Just what I needed to solve a problem I've been having. Thanks Mateus!

    •  4 місяці тому

      Glad you liked it!

  • @neverything
    @neverything 11 місяців тому +1

    Thanks for this Mateus, so well explained

    •  11 місяців тому

      Glad it was helpful!

  • @TravisFont
    @TravisFont 11 місяців тому +1

    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.

    •  11 місяців тому

      Thanks!

  • @abdallakaram5376
    @abdallakaram5376 11 місяців тому +1

    love that in depth content thanks 🙏

    •  11 місяців тому

      Glad you enjoy it!

  • @hamidrezahassani4006
    @hamidrezahassani4006 11 місяців тому

    great video. like always

    •  11 місяців тому

      I appreciate that

  • @g4mrplays
    @g4mrplays 11 місяців тому

    3:58, why would the hash produce the same index?

    •  11 місяців тому +1

      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?

    •  11 місяців тому

      The hash produces an integer that IS USED as an index. Within a limited memory space you’re bound to have collisions.