当前位置: 首页>>代码示例>>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;未经允许,请勿转载。