gmlconstraintzmod.java

来自「p2p仿真器。开发者可以工作在覆盖层中进行创造和测试逻辑算法或者创建和测试新的服」· Java 代码 · 共 67 行

JAVA
67
字号
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 + =
减小字号Ctrl + -
显示快捷键?