當前位置: 首頁>>代碼示例>>Java>>正文


Java Direction.getRight方法代碼示例

本文整理匯總了Java中com.cburch.logisim.data.Direction.getRight方法的典型用法代碼示例。如果您正苦於以下問題:Java Direction.getRight方法的具體用法?Java Direction.getRight怎麽用?Java Direction.getRight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cburch.logisim.data.Direction的用法示例。


在下文中一共展示了Direction.getRight方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findShortestPath

import com.cburch.logisim.data.Direction; //導入方法依賴的package包/類
private static SearchNode findShortestPath(List<SearchNode> nodes, Set<Location> pathLocs, AvoidanceMap avoid) {
	PriorityQueue<SearchNode> q = new PriorityQueue<SearchNode>(nodes);
	HashSet<SearchNode> visited = new HashSet<SearchNode>();
	int iters = 0;
	while (!q.isEmpty() && iters < MAX_SEARCH_ITERATIONS) {
		iters++;
		SearchNode n = q.remove();
		if (iters % 64 == 0 && ConnectorThread.isOverrideRequested() || n == null) {
			return null;
		}
		if (n.isDestination()) {
			return n;
		}
		boolean added = visited.add(n);
		if (!added) {
			continue;
		}
		Location loc = n.getLocation();
		Direction dir = n.getDirection();
		int neighbors = 3;
		Object allowed = avoid.get(loc);
		if (allowed != null && n.isStart() && pathLocs.contains(loc)) {
			allowed = null;
		}
		if (allowed == ALLOW_NEITHER) {
			neighbors = 0;
		} else if (allowed == ALLOW_VERTICAL) {
			if (dir == null) {
				dir = Direction.NORTH;
				neighbors = 2;
			} else if (dir == Direction.NORTH || dir == Direction.SOUTH) {
				neighbors = 1;
			} else {
				neighbors = 0;
			}
		} else if (allowed == ALLOW_HORIZONTAL) {
			if (dir == null) {
				dir = Direction.EAST;
				neighbors = 2;
			} else if (dir == Direction.EAST || dir == Direction.WEST) {
				neighbors = 1;
			} else {
				neighbors = 0;
			}
		} else {
			if (dir == null) {
				dir = Direction.NORTH;
				neighbors = 4;
			} else {
				neighbors = 3;
			}
		}
		for (int i = 0; i < neighbors; i++) {
			Direction oDir;
			switch (i) {
			case 0:
				oDir = dir;
				break;
			case 1:
				oDir = neighbors == 2 ? dir.reverse() : dir.getLeft();
				break;
			case 2:
				oDir = dir.getRight();
				break;
			default: // must be 3
				oDir = dir.reverse();
			}
			SearchNode o = n.next(oDir, allowed != null);
			if (o != null && !visited.contains(o)) {
				q.add(o);
			}
		}
	}
	return null;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:76,代碼來源:Connector.java


注:本文中的com.cburch.logisim.data.Direction.getRight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。