in reply to Re: can I change hash keys or values directly
in thread can I change hash keys or values directly

TYVM!

I pretty familiar with hash internals from a user viewpoint but your details were most instructive. I read it twice but may need to read a few more times to let it sink in..

Curiously, I recall my FIRST programming assignment, way back in 1977, in APL, was to write a hash table manager, which stored and retrieved hashed elements. Thinking back to how that worked- I get what you're saying. Its not stored as an array (even though keys %h returns one).. I also recall writing a non-hashed storage manager and for reasonably-sized tables, the speeds were of course much better. I get that :)

Much appreciated you are the guru of Perl Hashes!

  • Comment on Re^2: can I change hash keys or values directly

Replies are listed 'Best First'.
Re^3: can I change hash keys or values directly
by LanX (Saint) on Feb 04, 2021 at 17:12 UTC
Re^3: can I change hash keys or values directly
by Marshall (Canon) on Feb 04, 2021 at 20:54 UTC
    I'm glad that you liked my post!

    I actually used the Perl hash algorithm in a C project once. So I got pretty far into how Perl did it.

    I wrote a .h file, memtracker.h for a local college. Students just included this .h file in their C or C++ program and magic happened. Without any source mods or link dependencies, this thing tracked C or C++ memory allocations and deallocations and when the user program exited, it showed whether there were any memory leaks and a table showing how all of this played out. It would say things like "on line X, that memory allocation has no corresponding deallocation", etc. Anyway I used a hash as the main data structure to keep track of things. Turned out to be a more complicated project that I had first thought - mainly due to making it work with 2 compilers each of C and C++ using the same single .h file. Final file was somewhat north of 1,500 lines of C with a lot of C pre-processor voo-doo. Anyway turned out to be a fun project. One C++ prof had his own version of this, but it was so slow, it was adding 20 minutes execution time to a large C++ lab! My version was so fast that it wasn't even user perceptible and it had more features. Using a very efficient data structure was a big part of the speed improvement.