Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Associative array

From Simple English Wikipedia, the free encyclopedia

Anassociative array is a special kind ofarray. Eachelement has a name or label instead of just a number. Usually, arrays use numbers to find things. With an associative array, the name or label is related to the element, askey tovalue (key-value or name-value). The key represents a name or label, that can be used to find the value of an element.

Example

[change |change source]
  • The associative array is assigned to avariable (var).
  • The "key" is used to find the "value" it contains.
var:={"key_1":"value_1","key_2":"value_2","key_3":"value_3"}

Uses

[change |change source]

Associative arrays, depending on theprogramming language, can be known by many different names. Such as:hashmap,hash table,hash,map,table, ordictionary.

InObjective-C,.NET,[1]Python,Swift,VBA they are calleddictionaries; inPerl,Ruby they are calledhashes; inC++,C#,Go,Haskell,Java,OCaml,Scala, andV (Vlang)[2] they are calledmaps; inLisp (Common Lisp) andWindows PowerShell, they are calledhash tables; inMaple andLua, they are calledtables. In theD language they are calledhash maps.[3]

InJavaScript (see alsoJSON), allobjectsbehave as associative arrays with string-value keys, while the Map and WeakMaptypes take objects as keys. In Lua, they are used as the building blocks for theirdata structures. InPHP andR, all arrays can be associative, but the keys are limited tointegers andstrings.

References

[change |change source]
  1. "Dictionary<TKey, TValue> Class". MSDN.
  2. Rao, Navule Pavan Kumar (December 10, 2021).Getting Started with V Programming. p. 103.ASIN B09FKK3JL7.ISBN 978-1839213434.OCLC 1290492862.
  3. "Associative Arrays, the D programming language". Digital Mars.
Retrieved from "https://simple.wikipedia.org/w/index.php?title=Associative_array&oldid=10354195"
Categories:

[8]ページ先頭

©2009-2026 Movatter.jp