Content deleted Content added
moved =PowerShell= up into alphabetic order |
section header edits for capitalization and whitespace consistency within the article |
||
Line 8:
The following is a comparison of [[associative array]]s (also "mapping", "hash", and "dictionary") in various programming languages.
=== [[Awk]] ===
Awk has built-in, language-level support for associative arrays.
Line 44:
</source>
=== [[C (programming language)| C ]] ===
There is no standard implementation of an associative array in C, but a 3rd party library with BSD license is available [http://www.cl.cam.ac.uk/~cwc22/hashtable/ here]{{Dead link|date=October 2011}} . [[POSIX]] 1003.1-2001 describes the functions <code>hcreate()</code>, <code>hdestroy()</code> and <code>hsearch()</code>.
Line 53:
Similar to [[Glib]], [[Apple Inc.|Apple]]'s cross-platform [[Core Foundation]] framework provides several basic data types. In particular, there are reference counted CFDictionary and CFMutableDictionary.
=== [[C Sharp (programming language)|C#]] ===
<source lang=CSharp>
Dictionary<string, string> dic = new Dictionary<string, string>();
Line 83:
</source>
=== [[C++]] ===
C++ also has a form of associative array called [[map (C++)|<code>std::map</code>]] (see [[Standard Template Library#Containers]]). One could create a map with the same information as above using C++ with the following code:
Line 144:
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> with the algorithmic characteristics of a hash table. This is a common vendor extension to the STL as well, usually called <code>hash_map</code>, being available from such implementations as SGI and STLPort.
=== [[ColdFusion]] ===
You can use a ColdFusion structure to perform as an associative array. Here is a sample in ColdFusion:
Line 638:
FOR S NAME=$ORDER(^phonebook(NAME)) QUIT:NAME="" WRITE NAME," Phone Number :",^phonebook(NAME),!
=== [[Objective-C]] (Cocoa/GNUstep) ===
[[Cocoa (API)]] and [[GNUstep]] handle associative arrays using <code>NSMutableDictionary</code> (a mutable version of <code>NSDictionary</code>) class cluster. This class allows assignments between any two objects to be made. A copy of the key object is made before it is inserted into <code>NSMutableDictionary</code>, therefore the keys must conform to the <code>NSCopying</code> protocol. When being inserted to a dictionary, the value object receives a retain message to increase its reference count. The value object will receive the release message when it will be deleted from the dictionary (both explicitly or by adding to the dictionary a different object with the same key).
Line 1,243:
</source>
=== [[Standard ML]] ===
The SML'97 standard of the Standard ML programming language does not provide any associative containers. However, various implementations of Standard ML do provide associative containers.
Line 1,296:
=== [[Tcl]] ===
There are two Tcl facilities that support associative array semantics. An
array is a collection of ''variables''. A '''dict''' is a full implementation
Line 1,416 ⟶ 1,415:
</source>
== References ==
{{Reflist|2}}
|