• map.js


    function Map() {
    var struct = function(key, value) {
    this.key = key;
    this.value = value;
    }
    var put = function(key, value){
    for (var i = 0; i < this.arr.length; i++) {
    if ( this.arr[i].key === key ) {
    this.arr[i].value = value;
    return;
    }
    }
    this.arr[this.arr.length] = new struct(key, value);
    }

    var get = function(key) {
    for (var i = 0; i < this.arr.length; i++) {
    if ( this.arr[i].key === key ) {
    return this.arr[i].value;
    }
    }
    return null;
    }

    var remove = function(key) {
    var v;
    for (var i = 0; i < this.arr.length; i++) {
    v = this.arr.pop();
    if ( v.key === key ) {
    continue;
    }
    this.arr.unshift(v);
    }
    }

    var size = function() {
    return this.arr.length;
    }

    var isEmpty = function() {
    return this.arr.length <= 0;
    }
    this.arr = new Array();
    this.get = get;
    this.put = put;
    this.remove = remove;
    this.size = size;
    this.isEmpty = isEmpty;
    }

  • 相关阅读:
    nginx 负载均衡
    nginX 安装 启动
    nginx 简介
    使用ASDM 管理 ciscoASA设备
    OSPF配置实验(一)
    VRRP
    HSRP 详解
    Rip 动态路由协议
    配置ASA防火墙 远程管理方式
    Oracle 重启监听
  • 原文地址:https://www.cnblogs.com/liuq1991/p/8119109.html
Copyright © 2020-2023  润新知