通过AS3词典高效循环 [英] Efficient looping through AS3 dictionary

查看:137
本文介绍了通过AS3词典高效循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for (var k in dictionary) 
{
  var key:KeyType = KeyType(k);
  var value:ValType = ValType(dictionary[k]); // <-- lookup
  // do stuff
}

这是我在一本字典通过条目中使用循环。正如你可以在每次迭代看我演出在字典中查找。有迭代词典(同时保持访问密钥)?

This is what I use to loop through the entries in a dictionary. As you can see in every iteration I perform a lookup in the dictionary. Is there a more efficient way of iterating the dictionary (while keeping access to the key)?

推荐答案

遍历&放大器;

for (var k:Object in dictionary) {
    var value:ValType = dictionary[k];
    var key:KeyType = k;
}

遍历更简洁:

for each (var value:ValType in dictionary) {

}

这篇关于通过AS3词典高效循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆