本文整理匯總了Java中java.util.Queue.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Queue.contains方法的具體用法?Java Queue.contains怎麽用?Java Queue.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Queue
的用法示例。
在下文中一共展示了Queue.contains方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateFromPoint
import java.util.Queue; //導入方法依賴的package包/類
public static Queue<Point> generateFromPoint(Point endPoint) {
// template as a traversal of generated graph
Queue<Point> visited = new LinkedList<>();
Point current = new Point(0, 0);
visited.add(current);
while (!current.equals(endPoint)) {
if ((lineGoesAboveCurrentNode(current, endPoint)
|| endIsExactlyAbove(current, endPoint))
&& !visited.contains(Direction.UP.shiftPoint(current))) {
current = Direction.UP.shiftPoint(current);
} else if ((lineGoesBelowCurrentNode(current, endPoint)
|| endIsExactlyBelow(current, endPoint))
&& !visited.contains(Direction.DOWN.shiftPoint(current))) {
current = Direction.DOWN.shiftPoint(current);
} else if (theEndIsToTheLeft(current, endPoint)) {
current = Direction.LEFT.shiftPoint(current);
} else if (theEndIsToTheRight(current, endPoint)) {
current = Direction.RIGHT.shiftPoint(current);
}
visited.add(current);
}
return visited;
}