in reply to datastructure of array and hash?
Perl internals (& my neophyte status) not withstanding, I can only offer the following... Every memory location in every computer ever made, is accessed "numerically". That's just the way things are, so if you want the corresponding "Value" of green to the "Key" of Color, You must use a "hashing algorithm" (ha)to compute a numerical memory address from the bits-value of 'color'. There are several known hashing Algorithms and each is designed to work better than another on different sizes of files, arays, tables, hashes, or what-have-you. On the systems I work on, we can set the seed of these ha's to 0,1,2,etc. & create a more efficient (polynomial)Algorithm as the file size increases. Not sure if perl utilizes different ha's internally or not. By accessing an Array via its relative numeric index, getting the nth element would be faster, but looking for the element containing 'Color' would require a sort & a B-Tree Algorithm, making it slower than a hash. IMHO, but again, I'm just learning. ;-) That's it, for what it's worth.
|