java.lang.Double.hashCode()方法的使用及代码示例

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

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

Double.hashCode介绍

[英]Returns a hash code for this Double object. The result is the exclusive OR of the two halves of the long integer bit representation, exactly as produced by the method #doubleToLongBits(double), of the primitive double value represented by this Double object. That is, the hash code is the value of the expression: (int)(v^(v>>>32)) where v is defined by: long v = Double.doubleToLongBits(this.doubleValue());
[中]返回此双精度对象的哈希代码。结果是长整数位表示的两半的异或,与此双对象表示的原语双值的#doubleToLongBits(double)方法产生的结果完全相同。也就是说,哈希代码是表达式:(int)(v^(v>>>32))的值,其中v由:long v=Double定义。doubleToLongBits(this.doubleValue());

代码示例

代码示例来源:origin: google/guava

/**
 * Returns a hash code for {@code value}; equal to the result of invoking {@code ((Double)
 * value).hashCode()}.
 *
 * <p><b>Java 8 users:</b> use {@link Double#hashCode(double)} instead.
 *
 * @param value a primitive {@code double} value
 * @return a hash code for the value
 */
public static int hashCode(double value) {
 return ((Double) value).hashCode();
 // TODO(kevinb): do it this way when we can (GWT problem):
 // long bits = Double.doubleToLongBits(value);
 // return (int) (bits ^ (bits >>> 32));
}

代码示例来源:origin: alibaba/druid

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + ((value == null) ? 0 : value.hashCode());
  return result;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return the same value as {@link Double#hashCode(double)}}.
 * @deprecated as of Spring Framework 5.0, in favor of the native JDK 8 variant
 */
@Deprecated
public static int hashCode(double dbl) {
  return Double.hashCode(dbl);
}

代码示例来源:origin: prestodb/presto

/**
 * Returns a hash code for {@code value}; equal to the result of invoking {@code ((Double)
 * value).hashCode()}.
 *
 * <p><b>Java 8 users:</b> use {@link Double#hashCode(double)} instead.
 *
 * @param value a primitive {@code double} value
 * @return a hash code for the value
 */
public static int hashCode(double value) {
 return ((Double) value).hashCode();
 // TODO(kevinb): do it this way when we can (GWT problem):
 // long bits = Double.doubleToLongBits(value);
 // return (int) (bits ^ (bits >>> 32));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return a hash code based on the contents of the specified array.
 * If {@code array} is {@code null}, this method returns 0.
 */
public static int nullSafeHashCode(@Nullable double[] array) {
  if (array == null) {
    return 0;
  }
  int hash = INITIAL_HASH;
  for (double element : array) {
    hash = MULTIPLIER * hash + Double.hashCode(element);
  }
  return hash;
}

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

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + ((score == null) ? 0 : score.hashCode());
  result = prime * result + ((value == null) ? 0 : value.hashCode());
  return result;
}

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

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + ((score == null) ? 0 : score.hashCode());
  result = prime * result + ((value == null) ? 0 : value.hashCode());
  return result;
}

代码示例来源:origin: apache/incubator-druid

@Override
public int hashCode()
{
 int result = Double.valueOf(estimate).hashCode();
 result = 31 * result + Double.valueOf(highBound).hashCode();
 result = 31 * result + Double.valueOf(lowBound).hashCode();
 result = 31 * result + Integer.valueOf(numStdDev).hashCode();
 return result;
}

代码示例来源:origin: stanfordnlp/CoreNLP

@Override
public int hashCode() {
 return (new Double(alpha)).hashCode();
}

代码示例来源:origin: apache/incubator-druid

@Override
public int hashCode()
{
 return (name.hashCode() * 31 + field.hashCode()) * 31 + Double.hashCode(fraction);
}

代码示例来源:origin: google/guava

@Override
public int hashCode() {
 return i.hashCode();
}

代码示例来源:origin: prestodb/presto

@Override
public int hashCode()
{
  double value = getValue(MILLISECONDS);
  return Double.hashCode(value);
}

代码示例来源:origin: prestodb/presto

@Override
public int hashCode()
{
  double value = getValue(Unit.BYTE);
  return Double.hashCode(value);
}

代码示例来源:origin: apache/incubator-druid

@Override
public int getUnsortedEncodedKeyComponentHashCode(@Nullable Double key)
{
 return DimensionHandlerUtils.nullToZero(key).hashCode();
}

代码示例来源:origin: prestodb/presto

@Override
  public int hashCode() { return Double.valueOf(doubleValue()).hashCode(); }
}

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

@Override
  public int hashCode() { return Double.valueOf(doubleValue()).hashCode(); }
}

代码示例来源:origin: alibaba/Sentinel

@Override
public int hashCode() {
  int result = super.hashCode();
  result = 31 * result + new Double(count).hashCode();
  result = 31 * result + timeWindow;
  result = 31 * result + grade;
  return result;
}

代码示例来源:origin: google/guava

public void testHashCode() {
 for (double value : VALUES) {
  assertEquals(((Double) value).hashCode(), Doubles.hashCode(value));
 }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@Deprecated
public void hashCodeWithDouble() {
  double dbl = 9830.43;
  int expected = (new Double(dbl)).hashCode();
  assertEquals(expected, ObjectUtils.hashCode(dbl));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testHashCode() {
  final MutableDouble mutNumA = new MutableDouble(0d);
  final MutableDouble mutNumB = new MutableDouble(0d);
  final MutableDouble mutNumC = new MutableDouble(1d);
  assertTrue(mutNumA.hashCode() == mutNumA.hashCode());
  assertTrue(mutNumA.hashCode() == mutNumB.hashCode());
  assertFalse(mutNumA.hashCode() == mutNumC.hashCode());
  assertTrue(mutNumA.hashCode() == Double.valueOf(0d).hashCode());
}

相关文章