zoukankan      html  css  js  c++  java
  • 706. 设计哈希映射

     1/**
    2 * Initialize your data structure here.
    3 */

    4var MyHashMap = function() {
    5    // 创建数组
    6    let MyHashMap = [];
    7};
    8
    9/**
    10 * value will always be non-negative.
    11 * @param {number} key
    12 * @param {number} value
    13 * @return {void}
    14 */

    15MyHashMap.prototype.put = function(key, value) {
    16    this[key] = value;
    17};
    18
    19/**
    20 * Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
    21 * @param {number} key
    22 * @return {number}
    23 */

    24MyHashMap.prototype.get = function(key) {
    25    return (this[key] === undefined) ? -1 : this[key];
    26};
    27
    28/**
    29 * Removes the mapping of the specified value key if this map contains a mapping for the key
    30 * @param {number} key
    31 * @return {void}
    32 */

    33MyHashMap.prototype.remove = function(key) {
    34    this[key] = -1;
    35};
    36
    37/**
    38 * Your MyHashMap object will be instantiated and called as such:
    39 * var obj = Object.create(MyHashMap).createNew()
    40 * obj.put(key,value)
    41 * var param_2 = obj.get(key)
    42 * obj.remove(key)
    43 */

  • 相关阅读:
    抽象
    数据处理—异常值处理
    数据处理—数据连续属性离散化
    数据处理—缺失值处理
    数据处理—归一化
    数据特征—正态性检验
    数据特征—相关性分析
    数据分析—统计分析
    数据特征—帕累托分析
    特征分析—对比分析
  • 原文地址:https://www.cnblogs.com/rencoo/p/10137817.html
Copyright © 2011-2022 走看看