java.util.AbstractMap.hashCode()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中java.util.AbstractMap.hashCode()方法的一些代码示例,展示了AbstractMap.hashCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractMap.hashCode()方法的具体详情如下:
包路径:java.util.AbstractMap
类名称:AbstractMap
方法名:hashCode

AbstractMap.hashCode介绍

[英]This implementation iterates its entry set, summing the hashcodes of its entries.
[中]此实现迭代其条目集,对其条目的哈希代码求和。

代码示例

代码示例来源:origin: apache/geode

@Override
public int hashCode() {
 int result = super.hashCode();
 result = 31 * result + region.hashCode();
 result = 31 * result + callbackArg.hashCode();
 return result;
}

代码示例来源:origin: geotools/geotools

/** Returns the hash code value for this map. */
@Override
public int hashCode() {
  return super.hashCode();
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Returns the hash code value for this map.
 */
public int hashCode() {
  synchronized (hash) {
    return super.hashCode();
  }
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Returns the hash code value for this map.
 */
@Override
public int hashCode() {
  synchronized (hash) {
    return super.hashCode();
  }
}

代码示例来源:origin: geosolutions-it/imageio-ext

/**
 * Returns the hash code value for this map.
 */
@Override
public int hashCode() {
  synchronized (hash) {
    return super.hashCode();
  }
}

代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-utilities

/**
 * Returns the hash code value for this map.
 */
@Override
public int hashCode() {
  synchronized (hash) {
    return super.hashCode();
  }
}

代码示例来源:origin: com.akiban/akiban-persistit

/**
 * Returns the hash code value for this map. The hash code is the sum of the
 * hash codes of each Map.Entry value in the entry set. The hash code value
 * is generally not useful on a backing database that is large and/or
 * changing, and therefore use of this method is discouraged in most cases.
 * 
 * @return the hash code value for this map.
 * @see java.util.Map.Entry#hashCode()
 * @see Object#hashCode()
 * @see Object#equals(Object)
 * @see Set#equals(Object)
 */
@Override
public int hashCode() {
  return super.hashCode();
}

代码示例来源:origin: eclipse/ditto

@Override
public int hashCode() {
  return Objects.hash(super.hashCode(), data);
}

代码示例来源:origin: stackoverflow.com

HashMap<String, String> myMap = new HashMap<String, String>(10);
myMap.put("key", "key");
System.out.println(myMap.hashCode());

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  // TODO Auto-generated method stub
  HashMap<Integer,Integer> keyMap=new HashMap<Integer, Integer>();
  keyMap.put(2, 1020);
  keyMap.put(3, 1352);
  keyMap.put(23,1256);
  System.out.println("hashcode keymap1:"+keyMap.hashCode());
  HashMap<Integer,Integer> keyMap2=new HashMap<Integer, Integer>();
  keyMap2.put(1, 100);
  keyMap2.put(4, 152);
  keyMap2.put(43,156);
  System.out.println("hashcode keymap2:"+keyMap2.hashCode()); 
  HashMap<HashMap<Integer,Integer>,String> mainMap=new HashMap<HashMap<Integer,Integer>,String>();
  mainMap.put(keyMap, "1st value");
  mainMap.put(keyMap2, "2ndvalue");
  System.out.println(mainMap);
  HashMap<Integer,Integer> keyMap3=new HashMap<Integer, Integer>();
  keyMap3.put(23,1256);
  keyMap3.put(3, 1352);
  keyMap3.put(2, 1020);
  System.out.println("hashcode keymap3:"+keyMap3.hashCode());
  mainMap.put(keyMap3, "3rd value");
  System.out.println(mainMap);
  if(mainMap.containsKey(keyMap3))
    System.out.println(" value retrieved is :"+mainMap.get(keyMap3));
  else
    System.out.println("key not found");

}

代码示例来源:origin: org.clapper/javautil

/**
 * <p>Returns the hash code value for this map. The hash code of a map
 * is defined to be the sum of the hash codes of each entry in the
 * map's <tt>entrySet()</tt> view. This ensures that
 * <tt>t1.equals(t2)</tt> implies that
 * <tt>t1.hashCode()==t2.hashCode()</tt> for any two maps <tt>t1</tt>
 * and <tt>t2</tt>, as required by the general contract of
 * Object.hashCode.</p>
 *
 * <p><b>Warning:</b>: The recommended hash code for each entry in the
 * <tt>entrySet()</tt> view is a combination of hash codes for the
 * entry's key and the entry's value. (See <tt>java.util.Map.Entry</tt>
 * for details.) Because the values in a <tt>FileHashMap</tt> object
 * are stored in a file, this method can be quite slow.</p>
 *
 * @return the hash code value for this map.
 *
 * @see Object#hashCode()
 * @see Object#equals(Object)
 * @see #equals(Object)
 */
public int hashCode()
{
  checkValidity();
  return super.hashCode();
}

代码示例来源:origin: stackoverflow.com

public static void main(String... args)
              throws IOException, ClassNotFoundException {
  HashMap<String, Object> fileObj = new HashMap<String, Object>();

  ArrayList<String> cols = new ArrayList<String>();
  cols.add("a");
  cols.add("b");
  cols.add("c");
  fileObj.put("mylist", cols);
  {
    File file = new File("temp");
    FileOutputStream f = new FileOutputStream(file);
    ObjectOutputStream s = new ObjectOutputStream(f);
    s.writeObject(fileObj);
    s.close();
  }
  File file = new File("temp");
  FileInputStream f = new FileInputStream(file);
  ObjectInputStream s = new ObjectInputStream(f);
  HashMap<String, Object> fileObj2 = (HashMap<String, Object>) s.readObject();
  s.close();

  Assert.assertEquals(fileObj.hashCode(), fileObj2.hashCode());
  Assert.assertEquals(fileObj.toString(), fileObj2.toString());
  Assert.assertTrue(fileObj.equals(fileObj2));
}

代码示例来源:origin: org.arakhne.afc.core/references

@Pure
@Override
public final int hashCode() {
  expurgeNow();
  return super.hashCode();
}

相关文章