zoukankan      html  css  js  c++  java
  • hashtable

    /**
    * Returns the value to which the specified key is mapped,
    * or {@code null} if this map contains no mapping for the key.
    *
    * <p>More formally, if this map contains a mapping from a key
    * {@code k} to a value {@code v} such that {@code (key.equals(k))},
    * then this method returns {@code v}; otherwise it returns
    * {@code null}. (There can be at most one such mapping.)
    *
    * @param key the key whose associated value is to be returned
    * @return the value to which the specified key is mapped, or
    * {@code null} if this map contains no mapping for the key
    * @throws NullPointerException if the specified key is null
    * @see #put(Object, Object)
    */
    @SuppressWarnings("unchecked")
    public synchronized V get(Object key) {
    Entry<?,?> tab[] = table;
    int hash = key.hashCode();
    int index = (hash & 0x7FFFFFFF) % tab.length;
    for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
    if ((e.hash == hash) && e.key.equals(key)) {
    return (V)e.value;
    }
    }
    return null;
    }

    根据key的hash值获取索引 然后取出数据
    你的数据本质存储在Entry数组中
    根据key的hash值 然后与特定数相与获取索引 然后存储
    取出也一样




  • 相关阅读:
    fork-vfork -exit&_exit
    drop_cache-sar
    性能问题eg
    性能工具-mem
    性能工具-io工具
    linux后台开发常用调试工具
    GDB的原理
    可变参数以及stdcall
    linux 中断softirq tasklet
    linux kernel RCU 以及读写锁
  • 原文地址:https://www.cnblogs.com/wwwsss/p/15594125.html
Copyright © 2011-2022 走看看