If your question is, and I'm way out on a limb here trying to interpret your question:

Can you correctly describe a hash as being implemented an array of pointers internally

then the answer is a qualified "Yes and No":)

In essence, a hash consists of a (c-style) array of pointers, with each pointer leading to a structure that contains two further pointers. One pointing to the key for element, and the other to value. When an element is accessed, the characters that make up the key are munged (Tech. term:) mathematically by some algorithm to yield an index into the array. The pointer in this location leads to the structure and thence the value (and a copy of the key).

If the array where infinite in size, and the munging (hashing) algorithm were perfect, that would enough, but in the real world infinite arrays don't exist and hashing algorithms are imperfect except for special cases of highly tailored algorithms for specific, limited key sets., so the has to be extra logic, flags and pointers to deal with collisions.

See Gisle Aas' PerlGuts Illustrated for the most accessible description of perls internals I've encountered (you'll need to scroll down a ways or search for "RITER, EITER" to find the description of Perls hashes. It also includes a really excellent picture of their layout HV.PNG.

My apologies in advance if I misinterpreted your question, but a mention of PerlGuts Illustrated and Gisle's generosity in making it available is worth it anyway.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

In reply to Re: Hash and Array by BrowserUk
in thread Hash and Array by donno20

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.