📄 hashfunction.java
字号:
/* * project: RebecaSim * package: broker * file: HashFunction.java * * version: 0.1 * date: 10.05.2005 * * This software is part of the diploma thesis "Ein adaptives Brokernetz * für Publish/Subscribe Systeme". */package broker;import java.util.*;/** * This class implements a simple hash function based on java's own * pseudo random generator. To hash a value the random generator's seed * is set to a value dependent bit pattern. The pattern is determined * by value xor hashseed, where hashseed is the hash functions own seed. * * @version 10.05.2005 * @author parzy */public class HashFunction { /** * The used random generator. */ private static Random rand = new Random(); /** * The hash functions own seed. */ private long seed; /** * Creates a hash function with the given seed. * @param seed the hash function's seed. */ public HashFunction(long seed){ this.seed = seed; } /** * Hashs the value. * @param value the value to hash. * @return the value's hash. */ public int hash(int value){ rand.setSeed(seed ^ value); return rand.nextInt(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -