AutoHotkey中Java的HashMap相当于什么?

时间:2017-08-17 20:24:11

标签: hashmap autohotkey

我有一组缩写的部门名称。我需要创建一个脚本,可以将这些缩写与他们的官方标题进行映射。 (例如:ADMIN→Administration)

在Java中,我可以使用HashMap来完成此任务。

public static void main() {
   HashMap hm = new HashMap(); // create hash map

   hm.put("ADMIN", "Administration");  // add elements to hashmap
   hm.put("RAD",   "Radiologist");
   hm.put("TECH",  "Technician");

   System.out.println("ADMIN is an abbreviation for " + hm.get("ADMIN"));
}

AutoHotkey中是否有相应的解决方案?

1 个答案:

答案 0 :(得分:2)

您可以使用Associative Array

实现键值对
  

关联数组是一个包含集合的对象   唯一键和值集合,每个键都与之关联   有一个值。键可以是字符串,整数或对象,而值   可以是任何类型。可以按如下方式创建关联数组:

$.map(fnFoes, function(i,obj){ 
        console.log(obj);
        console.log('loadAllAvatars: checking foe: ' + obj);

        if (!(obj in foes) || fnFoes[obj].avatar != foes[obj].avatar || document.getElementById(obj) === null){ // compare avatar information of both variables. if changed, render new
            console.log('loadAllAvatars: foe '+ obj +' will be rendered');
            foeRenderIds.push(obj); // push foe id in list
            if (obj in foes) {
                foes[obj].avatar = fnFoes[obj].avatar; // change avatar items in foes;
            }

            var avatar = fnFoes[obj].avatar.split(','); // split avatar string in array
            console.log(avatar);
            console.log(fnFoes[obj]);
            if (document.getElementById('#'+obj)){ // if foe div already exists in avatarDoubles, just delete it
                $('#'+obj).html(); // delete old avatar from doubles
            } else {
                var html ='<div id="foe' + obj + '"></div>'; // if avatar doesn't exist, create it in avatarDoubles
                $('#avatarDoubles').append(html);
            }

            //render avatar
            if (typeof avatar !== 'undefined' && avatar.length > 1) {
               $.map(avatar, function(j,key){
                  console.log(avatar[key]);
                  var name = avatar[key];  
                  db.svgs.get(name).then(function(obj2){
                      var html = "<div class='" + obj2.category + "'  data-name='" + obj2.name + "' data-category='" + obj2.category + "'>" + obj2.svg + "</div>";
                      $('#foe' + obj).append(html);
                      console.log(obj2.name);
                  });

                });
            }                  
        } else {
            console.log('loadAllAvatars: foe '+ obj +' already exists');  
        }
});

这是一个数组,它使用作业的缩写名称(Array := {KeyA: ValueA, KeyB: ValueB, ..., KeyZ: ValueZ} )来查找完整的显示名称(key)。

value