/** * Process a commit to see if it has already been seen. If it has, prevent unnecessary work from * continuing on the other traversal queue. If it hasn't, add it's parents to the traversal * queue. * * @param commit commit to process * @param myQueue my traversal queue * @param mySet my visited nodes * @param theirQueue other traversal queue * @param theirSet other traversal's visited nodes * @return */ private boolean processCommit(GraphNode commit, Queue<GraphNode> myQueue, Set<GraphNode> mySet, Queue<GraphNode> theirQueue, Set<GraphNode> theirSet) { if (mySet.add(commit)) { if (theirSet.contains(commit)) { stopAncestryPath(commit, theirQueue, theirSet); return true; } Iterator<GraphEdge> edges = commit.getEdges(Direction.OUT); while (edges.hasNext()) { GraphEdge parentEdge = edges.next(); GraphNode parent = parentEdge.getToNode(); myQueue.add(parent); } } return false; }
/** * Process a commit to see if it has already been seen. If it has, prevent unnecessary work from * continuing on the other traversal queue. If it hasn't, add it's parents to the traversal * queue. * * @param commit commit to process * @param myQueue my traversal queue * @param mySet my visited nodes * @param theirQueue other traversal queue * @param theirSet other traversal's visited nodes * @return */ private boolean processCommit(GraphNode commit, Queue<GraphNode> myQueue, Set<GraphNode> mySet, Queue<GraphNode> theirQueue, Set<GraphNode> theirSet) { if (mySet.add(commit)) { if (theirSet.contains(commit)) { stopAncestryPath(commit, theirQueue, theirSet); return true; } Iterator<GraphEdge> edges = commit.getEdges(Direction.OUT); while (edges.hasNext()) { GraphEdge parentEdge = edges.next(); GraphNode parent = parentEdge.getToNode(); myQueue.add(parent); } } return false; }