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

📄 gmlconstraintzmod.java

📁 p2p仿真器。开发者可以工作在覆盖层中进行创造和测试逻辑算法或者创建和测试新的服务。PlanetSim还可以将仿真代码平稳转换为在Internet上的实验代码
💻 JAVA
字号:
package planet.chord;

import planet.commonapi.Id;
import planet.commonapi.results.ResultsConstraint;
import planet.commonapi.results.ResultsEdge;

/**
 * Constraints for GML edge selection according to Integer congruences partitions. 
 * @author Marc Sanchez <marc.sanchez@estudiants.urv.es>
 */
public class GMLConstraintZmod implements ResultsConstraint {
	// Z mod set
	protected int Zmod;
	// partition class of Z mod set.
	protected int pt;

	// Constructor
	public GMLConstraintZmod(int Zmod, int pt) {
		// Z mod set
		this.Zmod = Zmod;
		// partition class of Z mod set.
		this.pt = pt;
	}
	/**
	 * @return Returns the partition equivalence class.
	 */
	public int getPt() {
		return pt;
	}
	/**
	 * @param pt The partition equivalence class to set.
	 */
	public void setPt(int pt) {
		this.pt = pt;
	}
	/**
	 * @return Returns the zmod.
	 */
	public int getZmod() {
		return Zmod;
	}
	/**
	 * @param zmod The zmod to set.
	 */
	public void setZmod(int zmod) {
		Zmod = zmod;
	}
	/* (non-Javadoc)
	 * @see planet.GML.GMLConstraint#isACompliantEdge(planet.GML.GMLEdgeImpl)
	 */
	public boolean isACompliantEdge(ResultsEdge e) {
		// Chord Id of 32 bits 
		long target = ((int[]) e.getTarget().getValue())[0] & 0x0ffffffffL;
		// Chord Id of 32 bits
		long source = ((int[]) e.getSource().getValue())[0] & 0x0ffffffffL;
		return (target % Zmod == pt) && (source  % Zmod == pt);
	}
	/* (non-Javadoc)
	 * @see planet.GML.GMLConstraint#isACompliantNode(planet.commonapi.Id id)
	 */
	public boolean isACompliantNode(Id id) {
		// Chord Id of 32 bits
		long Nid = ((int []) id.getValue())[0] & 0x0ffffffffL;
		return Nid % Zmod == pt;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -