Editing Map

Jump to: navigation, search

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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 8: Line 8:
 
* ''Iterate'' through the map, obtaining all key-value pairs stored therein.
 
* ''Iterate'' through the map, obtaining all key-value pairs stored therein.
  
In statically typed programming languages, the keys must all be of the same type (''key type''), and the values must also all be of the same type (''value type''). (However, statically typed languages ''do'' often provide a means to achieve varied value types in one map, such as C's void pointers, and Java's generic <code>Object</code> type.) In dynamically typed languages, the values do not necessarily have to be of the same type, but the keys most often are.
+
In statically typed programming languages, the keys must all be of the same type (''key type''), and the values must also all be of the same type (''value type''). In dynamically typed languages, the values do not necessarily have to be of the same type, but the keys most often are.
  
 
The map is a generalized form of the [[array]]. Whereas the array requires indices to be consecutive elements of a well-ordered set, a map allows keys of arbitrary type (subject to restrictions imposed by implementation). An important difference, however, is that whereas an array requires memory proportional to the difference between its smallest and largest index, a map usually only requires memory proportional to the amount of data it contains (that is, the total size of the key-value pairs stored therein). There is a trade-off associated with the increased flexibility and lower memory usage, however; operations on maps are invariably slower than operations on arrays, because nontrivial algorithms are required to maintain the map's internal representation in memory.
 
The map is a generalized form of the [[array]]. Whereas the array requires indices to be consecutive elements of a well-ordered set, a map allows keys of arbitrary type (subject to restrictions imposed by implementation). An important difference, however, is that whereas an array requires memory proportional to the difference between its smallest and largest index, a map usually only requires memory proportional to the amount of data it contains (that is, the total size of the key-value pairs stored therein). There is a trade-off associated with the increased flexibility and lower memory usage, however; operations on maps are invariably slower than operations on arrays, because nontrivial algorithms are required to maintain the map's internal representation in memory.

Please note that all contributions to PEGWiki are considered to be released under the Attribution 3.0 Unported (see PEGWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)
Retrieved from "https://wcipeg.com/wiki/Map"