import Sprite3D = Laya.Sprite3D; export default class ResDic { private _length:number; public _container:{[id:number]:Laya.Image}; constructor(){ this._container = {}; this._length = 0; } public get container():{[id:number]:Laya.Image}{ return this._container; } //获取字典长度 public get size():number{ return this._length; } //添加 public set(key:any,value:any):void{ if(!this._container.hasOwnProperty(key)) { this._length++; } this._container[key] = value; } //查找 public has(key:any):boolean{ return this._container.hasOwnProperty(key)?true:false; } //获取 public get(key:any):any{ if(this._container.hasOwnProperty(key)) { return this._container[key]; }else { return undefined } } //删除 public delete(key:any):void{ if(this._container.hasOwnProperty(key)) { delete this._container[key]; this._length--; } } //清空 public clear(){ this._container = {}; this._length = 0; } }