1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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;
- }
-
- }
|