Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Associative array
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Ordered dictionary == The basic definition of a dictionary does not mandate an order. To guarantee a fixed order of enumeration, ordered versions of the associative array are often used. There are two senses of an ordered dictionary: * The order of enumeration is always deterministic for a given set of keys by sorting. This is the case for tree-based implementations, one representative being the {{code|<map>}} container of C++.<ref>{{cite web |title=std::map |url=https://en.cppreference.com/w/cpp/container/map |website=en.cppreference.com}}</ref> * The order of enumeration is key-independent and is instead based on the order of insertion. This is the case for the "ordered dictionary" in [[.NET Framework]], the LinkedHashMap of [[Java (programming language)|Java]] and [[Python (programming language)|Python]].<ref>{{cite web |title=OrderedDictionary Class (System.Collections.Specialized) |url=https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.ordereddictionary?view=netframework-4.8 |website=MS Docs |language=en-us}}</ref><ref>{{cite web |title=LinkedHashMap |url=https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/LinkedHashMap.html}}</ref><ref>{{cite web |title=collections β Container datatypes β Python 3.9.0a3 documentation |url=https://docs.python.org/3.9/library/collections.html#collections.OrderedDict |website=docs.python.org}}</ref> The latter is more common. Such ordered dictionaries can be implemented using an [[association list]], by overlaying a [[doubly linked list]] on top of a normal dictionary, or by moving the actual data out of the sparse (unordered) array and into a dense insertion-ordered one.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)