tintparamhashmap.java

来自「垃圾邮件过滤器源代码」· Java 代码 · 共 49 行

JAVA
49
字号
package opennlp.maxent;import gnu.trove.TIntDoubleHashMap;/** * Data structure for storing a models parameters for each outcome associated with a specific context.  */public class TIntParamHashMap extends TIntDoubleHashMap {  public TIntParamHashMap() {    super();  }    public TIntParamHashMap(int initialCapacity) {    super(initialCapacity);  }    public TIntParamHashMap(int initialCapacity, float loadFactor) {    super(initialCapacity, loadFactor);  }    public double get(int key) {    int hash, probe, index, length;    int[] set;    byte[] states;    states = _states;    set = _set;    length = states.length;    hash = key & 0x7fffffff;    index = hash % length;    if (states[index] != FREE &&        (states[index] == REMOVED || set[index] != key)) {        // see Knuth, p. 529        probe = 1 + (hash % (length - 2));        do {            index -= probe;            if (index < 0) {                index += length;            }        } while (states[index] != FREE &&                 (states[index] == REMOVED || set[index] != key));    }    return states[index] == FREE ? 0d : _values[index];  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?