what are the performance issues related to hashmap vs arrays.
also is this true:
hash(“duck”) = 1
hash(“pond”) = 5
if the hash function maps “duck” to 1 and “pond” to 5, will the array in memory look like this:
[0] => “”
[1] => “duck”
[2] => “”
[3] => “”
[4] => “”
[5] => “pond”
so therefore hashmaps create unused space… ?
a friend of mine used Hash method to combine data… confused the hell out of me… i’m still new to it.
I think the OP meant hash functions not hash lists. Hash functions process input using string / math manipulations. So in fact, there is no “unused space” as it is calculated when called, maybe some overused CPU cycles
Do you mean if you create an array like this:
array(
1 => "duck",
5 => "pond"
)
Then maybe but in PHP there is no distinction between hashes and arrays, they are both one in the same in PHP.
See: http://us.php.net/manual/en/language.types.array.php