zoukankan      html  css  js  c++  java
  • Singleton

    public class Singleton
        {
            private static var _instanceDict :Dictionary = new Dictionary();
            public static function getInstance(type : Class, autoCreation : Boolean = true) : *
            {
                if(!_instanceDict[type] && autoCreation)
                {
                    _instanceDict[type] = true;
                    _instanceDict[type] = new type();
                }
                return _instanceDict[type];
            }
            public static function assertSingle(type : Class) : void
            {
                var tag : * = _instanceDict[type];

                if(!tag || tag is type)
                {
                    throw new Error("can't be instantiated whith new, please use single()");
                }
            }
            public static function hasInstance(type : Class) : Boolean
            {
                return (_instanceDict[type] != null);
            }
        }

  • 相关阅读:
    7. Bagging & Random Forest
    VS 多工程代码编写
    C++(vs)多线程调试 (转)
    halcon发布
    windows 批处理文件调用exe
    Halcon编程-基于形状特征的模板匹配
    缺陷检测 深度学习
    PID控制
    去掉图片中的红色标记的方法?
    图像处理之图像拼接四
  • 原文地址:https://www.cnblogs.com/happysky97/p/3064960.html
Copyright © 2011-2022 走看看