⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hashfunction.java

📁 发布/订阅系统路由重配算法,可应用于ad hoc环境
💻 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 + -