zoukankan      html  css  js  c++  java
  • As3.0中的Dictionary使用测试

    代码如下:

    package
    {
        import flash.display.Sprite;
        import flash.utils.Dictionary;
        
        public class AsTestDemo extends Sprite
        {
            public function AsTestDemo()
            {
                //类似于Java中的Map
                var dict:Dictionary = new Dictionary();
                
                //Dictionary强大之处
                dict[3.01] = "vokie";
                dict["123"] = -100;
                dict[123] = 100;
                dict[8] = 2.11;
                
                trace(dict[3.01]);
                trace(dict.hasOwnProperty(3+0.01)); //Java.Map.ContainsKey
                trace(dict.hasOwnProperty("3.01"));
                trace(dict.hasOwnProperty(123));
                trace(dict.hasOwnProperty(1234));
                trace("--------------------");
                for(var s1:String in dict)  //for(in)语句迭代key
                {
                    trace("key:"+s1);
                }
                trace("--------------------");
                for each(var s2:String in dict) //for each(in)语句迭代value
                {
                    trace("value:"+s2);
                }
            }
        }
    }


    运行结果:

    vokie
    true
    true
    true
    false
    --------------------
    key:8
    key:123
    key:3.01
    --------------------
    value:2.11
    value:100
    value:vokie


    测试结果中的键值覆盖,以及key、value的类型很随意,无需一一对应,使用的时候需要注意

  • 相关阅读:
    HDS推出HUS中端阵列 文件、块和对象统一存储
    Volume Shadow Copy Service(VSS)如何工作
    vmware备份
    vdp介绍
    DFS研究
    重设域管理员密码-window server 2008 R2
    Using LACP with a vSphere Distributed Switch 5.1
    To LACP or not to LACP (on a 5.1 vDS)
    iSCSI Network Designs: Part 5 – iSCSI Multipathing, Host Bus Adapters, High Availability and Redundancy
    Multipathing for Software iSCSI
  • 原文地址:https://www.cnblogs.com/vokie/p/3602070.html
Copyright © 2011-2022 走看看