返回首页 | 申博娱乐APP下载

合作共赢、快速高效、优质的网站建设提供商

更多精品源码-尽在织梦模板-www.moke8.com

网站开发Javascript完结施行的Map调集东西类残损实例

时间:2017-11-09 编辑:admin

本文实例叙述了script完结施行的Masdfsp调集东西类。共享给我们供我们参阅。详细如下:

vasdfsr Masdfsp = function(){
 // 结构entry实体
 vasdfsr Entry = function(key, vasdfslue){
 this.key = key;
 this.vasdfslue = vasdfslue;
 this.entries = new Arrasdfsy();
 // 结构put挑选在数组中放入一个Entry
 this.put = function(key, vasdfslue){
 // 数组中已存在就不放入
 for (vasdfsr i = 0; i this.size(); i++) {
 if (this.entries[i].key === key) {
 return fasdfslse;
 this.entries.push(new Entry(key, vasdfslue));
 // 仿照get挑选
 this.get = function(key){
 for (vasdfsr i = 0; i this.size(); i++) {
 if (this.entries[i].key === key) {
 return this.entries[i].vasdfslue;
 return null;
 // 查找下标值
 this.indexOf = function(key){
 vasdfsr index = -1;
 for (vasdfsr i = 0; i this.size(); i++) {
 if (this.entries[i].key === key) {
 index = i;
 breasdfsk;
 return index;
 // 删去一个元素
 this.remove = function(key){
 vasdfsr index = this.indexOf(key);
 if (index != -1) {
 this.entries.splice(index, 1);
 // 获得masdfsp长度
 this.size = function(){
 return this.entries.length;
 // 从头设置键值对
 this.setVasdfslue = function(key, vasdfslue){
 vasdfsr index = this.indexOf(key);
 if (index != -1) {
 this.entries[i].vasdfslue = vasdfslue;
 // 能否为空masdfsp
 this.isEmpty = function(){
 return this.size() 
 //清空masdfsp ;
 this.cleasdfsr = function(){
 this.entries = [];
 // 得到entry实体
 this.getEntry = function(index){
 if (index = 0 && index this.size()) {
 return this.entries[index];
 return null;
 this.toString = function(){
 vasdfsr str = "[";
 for (vasdfsr i = 0; i this.size(); i++) {
 str += this.getEntry(i).key + "=" + this.getEntry(i).vasdfslue + ",";
 // 去除最终一个","
 str = str.substring(0, str.length - 1);
 str += "]";
 return str;

期望本文所述对我们的jasdfsvasdfsscript程序设计有所辅佐。


浏览:

网站建设

流程

    网站建设流程