/** Get the index of a node. Simply scans through the array returned by {@link #getNodes}. * @param node the node * @return the index, or <code>-1</code> if the node was not found */ public int indexOf(final Node node) { Node[] arr = getNodes(); for (int i = 0; i < arr.length; i++) { if (node.equals(arr[i])) { return i; } } return -1; }
return left.equals(right);
if (newNode.equals(oldNode)) {
private int rowForNode(Node node) { for (int i = 0; i < nodeRows.length; i++) { if (node.equals(nodeRows[i])) { return i; } } return -1; }
for (final Node temp : edges.get(current)){ if(temp.equals(node2)){ return true; } else { stack.push(temp); } }
private int rowForNode(Node node) { for (int i = 0; i < nodeRows.length; i++) { if (node.equals(nodeRows[i])) { return i; } } return -1; }
private int rowForNode(Node node) { for (int i = 0; i < nodeRows.length; i++) { if (node.equals(nodeRows[i])) return i; } return -1; }
private int rowForNode(Node node) { for (int i = 0; i < nodeRows.length; i++) { if (node.equals(nodeRows[i])) return i; } return -1; }
@Override public int compare(Node n1, Node n2) { // TODO Auto-generated method stub if(n1.cost > n2.cost) return 1; else if(n1.cost < n2.cost) return -1; else return ( n1.equals(n2)? 0 : 1); }
for(int i=0; i<rootChildren.length; i++){ Node rootChild = rootChildren[i]; //see if the addChar1 already exists in the tree //if it doesn't if(!rootChild.equals(addChar1)){ //add the addChar1 as a child of the root root.addChild(addChar1); } else{ System.out.println(addChar1.getItem() + " Exists in the tree already"); }
ArrayList<Node> tempList = new ArrayList<Node>(); Node head = nodesAttachedTo.get(0); //get the head of the list tempList.add(head); Node runner = head; runner = runner.next; while (!runner.equals(head)) { tempList.add(runner); runner = runner.next; }
private HashMap<Source, ArrayList<Node>> sourceMap = new HashMap<Source, ArrayList<Node>>(); private HashMap<Target, ArrayList<Node>> targetMap = new HashMap<Target, ArrayList<Node>>(); private HashMap<Cost, ArrayList<Node>> costMap = new HashMap<Cost, ArrayList<Node>>(); /** Look for a node with a given source */ for( Node node : sourceMap.get(keySource) ) { /** Test the node for equality with a given node. Equals method below */ if(node.equals(nodeYouAreLookingFor) { return node; } }
/** Checks whether given Node is a subnode of rootContext. * @return true if specified Node is under current rootContext */ private boolean isUnderRoot(Node rootContext, Node node) { while (node != null) { if (node.equals(rootContext)) { return true; } node = node.getParentNode(); } return false; }
/** Checks whether given Node is a subnode of rootContext. * @return true if specified Node is under current rootContext */ private boolean isUnderRoot(Node node) { while (node != null) { if (node.equals(rootContext)) return true; node = node.getParentNode(); } return false; }
/** Checks whether given Node is a subnode of rootContext. * @return true if specified Node is under current rootContext */ private boolean isUnderRoot(Node node) { while (node != null) { if (node.equals(rootContext)) { return true; } node = node.getParentNode(); } return false; }
private boolean treeCompare(Node firstNode, Node secondNode) { if (firstNode == secondNode) return true; if (firstNode == null || !firstNode.equals(secondNode)) return false; return treeCompare(firstNode.left, secondNode.left) && treeCompare(firstNode.right, secondNode.right); }
private boolean isSelected(TestMethodNode testMethod, Node selected) { if (testMethod.equals(selected)) { return true; } for (Node node : testMethod.getChildren().getNodes()) { if (node.equals(selected)) { return true; } } return false; }
@Override protected void filterChildrenAdded (NodeMemberEvent ev) { super.filterChildrenAdded (ev); if (getTemplateRootNode ().equals (this.getNode ())) { sortNodes (); } }
@Override protected void addNotify () { super.addNotify (); if (getTemplateRootNode ().equals (this.getNode ())) { sortNodes (); } }
public int countPaths(Graph graph, Node u, Node v) { nodes = graph.getNodes(); edges = new ArrayList<>(graph.getEdges()); if (u.equals(v)) return 1; int count = 0; List<Edge> neighbours = u.getNeighbouringEdges(edges); for(Edge edge : neighbours){ w = edge.getTo(); count += countPaths(graph, w, v); } return count; }