createHashMapFromArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " \| *(game[0-9]|version[0-9]|gr[0-9]|serverExec|mp|pr|descr|s[0-9]|p[0-9]{1,3}|r[0-9]|x1?[0-9]|seealso) *= +" to " |$1= ")
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 5: Line 5:


|gr1= HashMap
|gr1= HashMap
|gr2= Arrays


|descr= Creates a new [[HashMap]] and initializes it from a key-value pair array
|descr= Creates a new [[HashMap]] and initializes it from a key-value pair array
Line 10: Line 12:
|s1= [[createHashMapFromArray]] [[key1, value1], [key2, value2]]  
|s1= [[createHashMapFromArray]] [[key1, value1], [key2, value2]]  


|p1= key: [[HashMapKey]]
|p1= keyN: [[HashMapKey]]


|p2= value: [[Anything]]
|p2= valueN: [[Anything]]


|r1= [[HashMap]]
|r1= [[HashMap]]


|s2= keys [[createHashMapFromArray]] values {{Since|arma3|2.04|y}}
|s2= keys [[createHashMapFromArray]] values
 
|s2since= arma3 2.04


|p21= keys: [[Array]] - Array of [[HashMapKey]]s
|p21= keys: [[Array]] of [[HashMapKey]]s


|p22= values: [[Array]] - Array of [[Anything|anything]]
|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]].}}
{{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]]
|r2= [[HashMap]]


|x1= <code>[[createHashMapFromArray]] [["a",1], ["b",2], ["c",3]];</code>
|x1= <sqf>createHashMapFromArray [["a", 1], ["b", 2], ["c", 3]];</sqf>


|x2= <code>[1,2,3,4] [[createHashMapFromArray]] [];{{cc|Returns [[1,<null>],[2,<null>],[4,<null>],[3,<null>]]}}</code>
|x2= <sqf>[1, 2, 3, 4] createHashMapFromArray []; // returns [[1, <null>], [2, <null>], [4, <null>], [3, <null>]]</sqf>


|x3= <code>[1,2,3] [[createHashMapFromArray]] ["one","two","three","four"];{{cc|Returns [[1,"one"],[2,"two"],[3,"three"]]}}</code></code>
|x3= <sqf>[1, 2, 3] createHashMapFromArray ["one", "two", "three", "four"]; // returns [[1, "one"], [2, "two"], [3, "three"]]</sqf>


|seealso= [[createHashMap]]
|seealso= [[createHashMap]]
}}
}}

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