Advertisement
Brick

Arma 3 Associative Array

Sep 8th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 0.96 KB | None | 0 0
  1. span class="re5"> mapGet =
  2. {
  3.     private _map = param [0, [], [[]], 2];
  4.     private _key = param [1, "", [""]];
  5.  
  6.     private _find = (_map select 0) find _key;
  7.  
  8.     if (_find isEqualTo -1) exitWith
  9.     {
  10.         // nil;
  11.     };
  12.  
  13.     (_map select 1) select _find;
  14. };
  15.  
  16. mapSet =
  17. {
  18.     private _map   = param [0, [], [[]], 2];
  19.     private _key   = param [1, "", [""]];
  20.     private _value = param [2];
  21.  
  22.     private _find = (_map select 0) find _key;
  23.  
  24.     if (_find isEqualTo -1) exitWith
  25.     {
  26.         (_map select 0) pushBack _key;
  27.         (_map select 1) pushBack _value;
  28.  
  29.         false;
  30.     };
  31.  
  32.     (_map select 1) set [_find, _value];
  33.  
  34.     true;
  35. };
  36.  
  37. mapRemove =
  38. {
  39.     private _map   = param [0, [], [[]], 2];
  40.     private _key   = param [1, "", [""]];
  41.  
  42.     private _find = (_map select 0) find _key;
  43.  
  44.     if (_find isEqualTo -1) exitWith
  45.     {
  46.         false;
  47.     };
  48.  
  49.     (_map select 0) deleteAt _find;
  50.     (_map select 1) deleteAt _find;
  51.  
  52.     true;
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement