FANDOM


16px-Pencil

A map, dictionary, or associative array, is a set of distinct keys (or indexes) mapped (or associated) to values. The association is such that the map will return the value when given the key. Using a map called a hashmap allows near instant look up time.

In some languages including PHP and JavaScript, a key must be either a string or a number.

Some possible implementations are: linked lists, B-trees, hashtables, and binary trees.

ExamplesEdit

PHPEdit

PHP's array type takes string keys directly.

$array = array('key' => 12345);

JavaScriptEdit

JavaScript regards objects as hashmaps.

var array = {key: 12345};

If an invalid identifier must be used as the key, it should be put in quotes.

var array = {'*key': 12345};

JavaEdit

import java.util.HashMap;

HashMap array = new HashMap();
array.put("key", new Integer(12345));

Groovy Edit

def array = ["key":12345]

ReferencesEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.