hashnode.java

来自「A framework written in Java for implemen」· Java 代码 · 共 65 行

JAVA
65
字号
// Copyright (c) 2005  Per M.A. Bothner.// This is free software;  for terms and warranty disclaimer see COPYING.package gnu.kawa.util;/** An entry in a {@link GeneralHashTable}. * This is a public class to allow overriding. */public class HashNode/* #ifdef JAVA2 */implements java.util.Map.Entry/* #endif */{  public HashNode next;  int hash;  Object key;  Object value;  public Object get (Object defaultValue)  {    return value;  }  public Object getKey ()  {    return key;  }  public Object getValue ()  {    return value;  }  public Object setValue (Object value)  {    Object old = this.value;    this.value = value;    return old;  }  /** Implements the general Map.Entry specification.   * But note that a GeneralHashTable subclass may override {@code matches},   * so it no longer uses equals, in which case it won't be consistent   * with this method, unless it is overridden. */  public boolean equals (Object o)  {    if (! (o instanceof HashNode))      return false;    HashNode h2 = (HashNode) o;    return (key == null ? h2.key == null : key.equals(h2.key))      && (value == null ? h2.value == null : value.equals(h2.value));  }  /** Implements the general Map.Entry specification.   * But note that a GeneralHashTable subclass may override {@code hash},   * so it no longer uses equals, in which case it won't be consistent   * with this method, unless it is overridden. */  public int hashCode ()  {    return (key ==null ? 0 : key.hashCode())      ^ (value==null ? 0: value.hashCode());  }}

⌨️ 快捷键说明

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