Content deleted Content added
Jerryobject (talk | contribs) m →CFML: WP:LINK update-standardize. MOS:FIRSTABBReviation clarify, define before WP:ABBR in parentheses. |
Jerryobject (talk | contribs) m Proper noun acronym > MOS:ALLCAPS. WP:LINK update-standardize. Section move to alphabetize. |
||
Line 8:
The following is a comparison of [[associative array]]s (also "mapping", "hash", and "dictionary") in various programming languages.
===
[[
For example:
Line 29:
The user can search for elements in an associative array, and delete elements from the array.
The following shows how multi-dimensional associative arrays can be simulated in standard
<syntaxhighlight lang=awk>
Line 173:
In C++, the <code>std::map</code> class is [[Generic programming#Templates in C.2B.2B|templated]] which allows the [[data type]]s of keys and values to be different for different <code>map</code> instances. For a given instance of the <code>map</code> class the keys must be of the same base type. The same must be true for all of the values. Although <code>std::map</code> is typically implemented using a [[self-balancing binary search tree]], C++11 defines a second map called <code>[[std::unordered_map]]</code>, which has the algorithmic characteristics of a hash table. This is a common vendor extension to the [[Standard Template Library]] (STL) as well, usually called <code>hash_map</code>, available from such implementations as SGI and STLPort.
===ColdFusion Markup Language===▼
A structure in [[ColdFusion Markup Language]] (CFML) is equivalent to an associative array:▼
<syntaxhighlight lang=CFS>▼
dynamicKeyName = "John Doe";▼
phoneBook = {▼
"Sally Smart" = "555-9999",▼
"#dynamicKeyName#" = "555-4321",▼
"J. Random Hacker" = "555-1337", ▼
UnknownComic = "???"▼
};▼
writeOutput(phoneBook.UnknownComic); // ???▼
writeDump(phoneBook); // entire struct▼
</syntaxhighlight>▼
===Cobra===
Line 212 ⟶ 197:
print "[key]'s phone number is [val]"
}}
▲===ColdFusion Markup Language===
▲A structure in [[ColdFusion Markup Language]] (CFML) is equivalent to an associative array:
▲<syntaxhighlight lang=CFS>
▲dynamicKeyName = "John Doe";
▲phoneBook = {
▲ "Sally Smart" = "555-9999",
▲ "#dynamicKeyName#" = "555-4321",
▲ "J. Random Hacker" = "555-1337",
▲ UnknownComic = "???"
▲};
▲writeOutput(phoneBook.UnknownComic); // ???
▲writeDump(phoneBook); // entire struct
▲</syntaxhighlight>
===D===
|