in reply to Re^2: Generating Unique numbers from Unique strings
in thread Generating Unique numbers from Unique strings
You are completely right: all the hash complexities are handled by perl. I've mention that to let the author of the original question got an impression, how it works, and, implement his own logic, if the standard hashes aren't enough for him.
BTW, does perl caches the string hash value? I.e. is the following approach:
my $index = $hash->{$string}; ... my $value1 = $array1->[$index]; my $value2 = $array2->[$index]; ... my $valueN = $arrayN->[$index];
comparing to the following approach:
my $value1 = $hash1->{$string}; my $value2 = $hash2->{$string}; ... my $valueN = $hashN->{$string};
I.e. I know that number of keys is fixed and isn't changed at runtime, so, I sort them, and store their order in hash, and then in future I always use arrays to store/retrieve values associated with string.
Is the first approach faster than the second?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Generating Unique numbers from Unique strings
by Marshall (Canon) on Apr 03, 2016 at 19:43 UTC | |
by BrowserUk (Patriarch) on Apr 03, 2016 at 19:52 UTC | |
by Marshall (Canon) on Apr 03, 2016 at 19:56 UTC | |
|
Re^4: Generating Unique numbers from Unique strings
by choroba (Cardinal) on Apr 03, 2016 at 16:23 UTC |