当前位置: 首页>>代码示例>>Java>>正文


Java Hasher.putDouble方法代码示例

本文整理汇总了Java中com.google.common.hash.Hasher.putDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Hasher.putDouble方法的具体用法?Java Hasher.putDouble怎么用?Java Hasher.putDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.hash.Hasher的用法示例。


在下文中一共展示了Hasher.putDouble方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCacheKey

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
public String getCacheKey() {
	Hasher hasher = hf.newHasher();
	hasher.putUnencodedChars(queryKey);
	for (Number id : ids) {
		if (id instanceof Integer) {
			hasher.putInt(id.intValue());
		} else if (id instanceof Long) {
			hasher.putLong(id.longValue());
		} else if (id instanceof Short) {
			hasher.putLong(id.shortValue());
		} else if (id instanceof Double) {
			hasher.putDouble(id.doubleValue());
		} else if (id instanceof Float) {
			hasher.putFloat(id.floatValue());
		} else if (id instanceof Byte) {
			hasher.putFloat(id.byteValue());
		}
	}
	HashCode hashcode = hasher.hash();
	return hashcode.toString();
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:22,代码来源:CacheDescriptor.java

示例2: testBasics

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Test
public void testBasics() {
    Hasher hasher = NullHasher.INSTANCE;
    assertEquals(0, hasher.hash().asInt());
    hasher.putBoolean(false);
    hasher.putByte((byte) 3);
    hasher.putBytes(new byte[0]);
    hasher.putBytes(null, 3, 3);
    hasher.putChar('c');
    hasher.putDouble(3.3);
    hasher.putFloat(3.4f);
    hasher.putInt(7);
    hasher.putLong(3);
    hasher.putObject(null, null);
    hasher.putShort((short) 7);
    hasher.putString(null, null);
    hasher.putUnencodedChars(null);
}
 
开发者ID:aws,项目名称:elastic-load-balancing-tools,代码行数:19,代码来源:NullHasherTest.java

示例3: hash

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public void hash(final Hasher hasher) {
    hasher.putInt(MetricType.SPREAD.ordinal());
    hasher.putLong(timestamp);
    hasher.putLong(count);
    hasher.putDouble(sum);
    hasher.putDouble(sum2);
    hasher.putDouble(min);
    hasher.putDouble(max);
}
 
开发者ID:spotify,项目名称:heroic,代码行数:11,代码来源:Spread.java

示例4: putDouble

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public Hasher putDouble(double d) {
  for (Hasher hasher : hashers) {
    hasher.putDouble(d);
  }
  return this;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:8,代码来源:AppendingHasher.java

示例5: hash

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/**
 * Utility method to compute an hash string from a vararg list of objects. The returned string
 * is 16 characters long, starts with {@code A-Za-z} and contains only characters
 * {@code A-Za-z0-9}.
 *
 * @param objects
 *            the objects to compute the hash from
 * @return the computed hash string
 */
public static String hash(final Object... objects) {
    final Hasher hasher = Hashing.md5().newHasher();
    for (final Object object : objects) {
        if (object instanceof CharSequence) {
            hasher.putString((CharSequence) object, Charsets.UTF_16LE);
        } else if (object instanceof byte[]) {
            hasher.putBytes((byte[]) object);
        } else if (object instanceof Character) {
            hasher.putChar((Character) object);
        } else if (object instanceof Boolean) {
            hasher.putBoolean((Boolean) object);
        } else if (object instanceof Integer) {
            hasher.putInt(((Integer) object).intValue());
        } else if (object instanceof Long) {
            hasher.putLong(((Long) object).longValue());
        } else if (object instanceof Double) {
            hasher.putDouble(((Double) object).doubleValue());
        } else if (object instanceof Float) {
            hasher.putFloat(((Float) object).floatValue());
        } else if (object instanceof Byte) {
            hasher.putByte(((Byte) object).byteValue());
        } else {
            hasher.putString(object.toString(), Charsets.UTF_16LE);
        }
    }
    final byte[] bytes = hasher.hash().asBytes();
    final StringBuilder builder = new StringBuilder(16);
    int max = 52;
    for (int i = 0; i < bytes.length; ++i) {
        final int n = (bytes[i] & 0x7F) % max;
        if (n < 26) {
            builder.append((char) (65 + n));
        } else if (n < 52) {
            builder.append((char) (71 + n));
        } else {
            builder.append((char) (n - 4));
        }
        max = 62;
    }
    return builder.toString();
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:51,代码来源:Data.java

示例6: hash

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public void hash(final Hasher hasher) {
    hasher.putInt(MetricType.POINT.ordinal());
    hasher.putDouble(value);
}
 
开发者ID:spotify,项目名称:heroic,代码行数:6,代码来源:Point.java


注:本文中的com.google.common.hash.Hasher.putDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。