createHashMapFromArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Create Page)
 
mNo edit summary
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command


|game1= arma3dev |Game name=
|game1= arma3
|version1= 2.02


|version= 2.01 |Game version=
|gr1= HashMap


____________________________________________________________________________________________
|gr2= Arrays


|descr= Creates a new [[HashMap]] and initializes it from a key-value pair array|Description=
|descr= Creates a new [[HashMap]] and initializes it from a key-value pair array


____________________________________________________________________________________________
|s1= [[createHashMapFromArray]] [[key1, value1], [key2, value2]]


| ''createHashMapFromArray''' [[key1, value1], [key2, value2]] |SYNTAX=
|p1= keyN: [[HashMapKey]]


|p1= key: [[HashMapKey]] |PARAMETER1=
|p2= valueN: [[Anything]]
|p2= value: [[Anything]] |PARAMETER2=


| [[HashMap]] |RETURNVALUE=
|r1= [[HashMap]]
____________________________________________________________________________________________


|x1= <code>createHashMapFromArray [["a",1], ["b",2], ["c",3]];</code> |Example 1=
|s2= keys [[createHashMapFromArray]] values


|x2= <code></code> |Example 2=
|s2since= arma3 2.04
____________________________________________________________________________________________


|seealso= [[HashMap]] |See Also=
|p21= keys: [[Array]] of [[HashMapKey]]s
}}
 
|p22= values: [[Array]] of [[Anything]]
{{Feature|informative|Size of ''keys'' and size of ''values'' arrays do not need to be equal. Missing values will be filled with [[nil]].}}
 
|r2= [[HashMap]]
 
|x1= <sqf>createHashMapFromArray [["a", 1], ["b", 2], ["c", 3]];</sqf>
 
|x2= <sqf>[1, 2, 3, 4] createHashMapFromArray []; // returns [[1, <null>], [2, <null>], [4, <null>], [3, <null>]]</sqf>


<dl class="command_description">
|x3= <sqf>[1, 2, 3] createHashMapFromArray ["one", "two", "three", "four"]; // returns [[1, "one"], [2, "two"], [3, "three"]]</sqf>
<!-- BEGIN Note Section -->
<!-- For example:
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
<dt class="note">[[User:User Name|User Name]]</dt>
<dd class="note">This is an example note. It is true and verifiable, and contains a little code snippet.
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
-->
<!-- END Note Section -->
</dl>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[createHashMap]]
<!-- Non-automatic appropriate categories go here, e.g
}}
[[Category:Scripting Commands {{arma3}}|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
-->

Latest revision as of 06:11, 27 November 2023

Hover & click on the images for description

Description

Description:
Creates a new HashMap and initializes it from a key-value pair array
Groups:
HashMapArrays

Syntax

Syntax:
createHashMapFromArray [[key1, value1], [key2, value2]]
Parameters:
keyN: HashMapKey
valueN: Anything
Return Value:
HashMap

Alternative Syntax

Syntax:
keys createHashMapFromArray values
Parameters:
keys: Array of HashMapKeys
values: Array of Anything
Size of keys and size of values arrays do not need to be equal. Missing values will be filled with nil.
Return Value:
HashMap

Examples

Example 1:
createHashMapFromArray [["a", 1], ["b", 2], ["c", 3]];
Example 2:
[1, 2, 3, 4] createHashMapFromArray []; // returns [[1, <null>], [2, <null>], [4, <null>], [3, <null>]]
Example 3:
[1, 2, 3] createHashMapFromArray ["one", "two", "three", "four"]; // returns [[1, "one"], [2, "two"], [3, "three"]]

Additional Information

See also:
createHashMap

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note