js封装的MAP
来源:互联网 发布:建筑节能设计分析软件 编辑:程序博客网 时间:2024/05/23 19:44
- function Map(){
- this.init();
- };
- //map的大小
- Map.prototype.size = function(){
- return this._size;
- };
- //将数据放入map中
- Map.prototype.put = function(key,value){
- if(!this.containsKey(key)){
- this.array[key] = value;
- this._size++;
- }
- };
- //根据key获得map的其中一个value
- Map.prototype.get = function(key){
- return this.array[key];
- };
- //map是否为空集合
- Map.prototype.isEmpty = function(){
- return this._size === 0;
- };
- //map集合是否包含key
- Map.prototype.containsKey = function(key){
- return this.array[key]!==undefined?true:false;
- };
- //移除指定的key
- Map.prototype.remove = function(key){
- if(this.containsKey(key)){
- delete this.array[key];
- this._size--;
- }
- };
- //移除所有集合
- Map.prototype.clear = function(){
- this.init();
- };
- //map集合转化成Array
- Map.prototype.toArray = function(){
- return this.array;
- };
- //初始化map集合
- Map.prototype.init = function(){
- this.array = new Array();
- this._size = 0;
- this._keySet = new Array();
- };
用法如下:
- var map = new Map();
- map.put("lynn","25");
- map.put("min","24");
- map.put("min1",0);
- map.remove("min");
- var arr = map.toArray();
- for(var i in arr){
- <span style="white-space:pre"> </span>alert(map.get(i));
- }
- js封装的MAP
- js封装map
- js Map封装
- js封装为map对象
- 为arcgis for js封装自己的map
- JS封装类似JAVA中的MAP
- JS封装类似JAVA中的MAP
- Ajax的js封装
- js类的封装
- JS的封装
- js类的封装
- js选择器的封装
- js的封装方法
- js方法的封装
- 原生JS的封装
- js的Map对象
- js实现的Map
- JS实现的MAP
- 师傅经验教导
- Android单独继承View类来实现自定义控件
- eclipse 设置。调优。使用
- Unix/Linux上进程标识赋值方法
- jQuery 自学笔记—10 常见特效 (终章)
- js封装的MAP
- 嗯,让我们彻底搞懂C/C++函数指针吧
- ffmpeg分析系列之三(输入输出格式)
- 一个简单的网页抓取例子
- 简单使用游标插入数据
- BSTR字符串的使用方法
- 急求思想--现在有一个3维模型的数据库,和有一张照片,如何从数据库中找到一个模型与图片匹配 求思想
- 透视投影
- 关于3n+1问题的验证