in reply to Re^3: Associative array
in thread Associative array
As Wikipedia says, an associative array is an abstract data type that maps a set of keys onto values. The analogy to an array is that arrays associate indexes with values, while associative arrays associate more general keys with values. So it is like an array, but with a more flexible choice of association. (Depending on the language and/or library, keys may even be arbitrary objects.) There are many ways to implement them. In fact the two Lisp examples you gave are valid (albeit inefficient) implementations!
The term "associative array" is used in many languages. You can see how ubiquitous the term is across languages by googling for associative array. When I did that, the top links were to the Wikipedia page I gave, then articles on PHP, JavaScript, Oracle PL/SQL, PHP again, an entry in a data structures dictionary, an article on C++ compilers, a Perl article, etc. Clearly the term is very well established in the broader programming world.
By contrast when we say hash we're referring to the implementation. Perl hashes are internally implemented using hash tables. (Common Lisp also has hash tables built in.) However there is no guarantee that Perl's hashes will always be so implemented. Perl has changed hashing algorithms in the past, and theoretically could switch to using a BTree at some point in the future. (Extremely unlikely though.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Associative array
by Anonymous Monk on Jul 13, 2009 at 10:04 UTC | |
|
Re^5: Associative array
by ELISHEVA (Prior) on Jul 13, 2009 at 11:59 UTC | |
by tilly (Archbishop) on Jul 13, 2009 at 19:05 UTC |