public void remove() { if (!isLeafNode()) { return; } if (this.parentNode != null) { this.parentNode.removeChild(this); } if (this.networkTopology != null) { this.networkTopology.removeNode(this); } }
protected NetworkNode(final String name, final NetworkNode parentNode, final NetworkTopology networkTopology) { this.name = name; this.parentNode = parentNode; this.networkTopology = networkTopology; if (this.parentNode != null) { this.parentNode.addChild(this); } if (this.networkTopology != null) { this.networkTopology.addNode(this); } }
public int getDepth() { if (this.isRootNode()) { return 1; } return (1 + this.parentNode.getDepth()); }
private void refillStack() { while (true) { final TraversalEntry traversalEntry = this.traversalStack.peek(); final NetworkNode networkNode = traversalEntry.getNetworkNode(); if (networkNode.isLeafNode()) { break; } final NetworkNode childNode = networkNode.getChildNode(traversalEntry.getChildrenVisited()); this.traversalStack.add(new TraversalEntry(childNode)); } }
@Override public NetworkNode next() { final TraversalEntry traversalEntry = this.traversalStack.pop(); final NetworkNode networkNode = traversalEntry.networkNode; if (!this.traversalStack.isEmpty()) { final TraversalEntry parentTraversalEntry = this.traversalStack.peek(); parentTraversalEntry.increaseChildrenVisited(); if (parentTraversalEntry.getChildrenVisited() < parentTraversalEntry.getNetworkNode() .getNumberOfChildNodes()) { refillStack(); } } return networkNode; }
NetworkTopologyIterator(final NetworkTopology networkTopology) { traversalStack.add(new TraversalEntry(networkTopology.getRootNode())); refillStack(); }
public int getDistance(final String nodeName) { final NetworkNode networkNode = this.networkTopology.getNodeByName(nodeName); if (networkNode == null) { return Integer.MAX_VALUE; } if (this.equals(networkNode)) { return 0; } return getDistance(networkNode); }
@Override public void read(final DataInput in) throws IOException { this.rootNode.read(in); }
@Override public String toString() { return this.rootNode.toString(); }
@Override public void write(final DataOutput out) throws IOException { this.rootNode.write(out); }
private void refillStack() { while (true) { final TraversalEntry traversalEntry = this.traversalStack.peek(); final NetworkNode networkNode = traversalEntry.getNetworkNode(); if (networkNode.isLeafNode()) { break; } final NetworkNode childNode = networkNode.getChildNode(traversalEntry.getChildrenVisited()); this.traversalStack.add(new TraversalEntry(childNode)); } }
@Override public NetworkNode next() { final TraversalEntry traversalEntry = this.traversalStack.pop(); final NetworkNode networkNode = traversalEntry.networkNode; if (!this.traversalStack.isEmpty()) { final TraversalEntry parentTraversalEntry = this.traversalStack.peek(); parentTraversalEntry.increaseChildrenVisited(); if (parentTraversalEntry.getChildrenVisited() < parentTraversalEntry.getNetworkNode() .getNumberOfChildNodes()) { refillStack(); } } return networkNode; }
public void remove() { if (!isLeafNode()) { return; } if (this.parentNode != null) { this.parentNode.removeChild(this); } if (this.networkTopology != null) { this.networkTopology.removeNode(this); } }
NetworkTopologyIterator(final NetworkTopology networkTopology) { traversalStack.add(new TraversalEntry(networkTopology.getRootNode())); refillStack(); }
protected NetworkNode(final String name, final NetworkNode parentNode, final NetworkTopology networkTopology) { this.name = name; this.parentNode = parentNode; this.networkTopology = networkTopology; if (this.parentNode != null) { this.parentNode.addChild(this); } if (this.networkTopology != null) { this.networkTopology.addNode(this); } }
public int getDepth() { if (this.isRootNode()) { return 1; } return (1 + this.parentNode.getDepth()); }
public int getDistance(final String nodeName) { final NetworkNode networkNode = this.networkTopology.getNodeByName(nodeName); if (networkNode == null) { return Integer.MAX_VALUE; } if (this.equals(networkNode)) { return 0; } return getDistance(networkNode); }
@Override public void read(final DataInput in) throws IOException { this.rootNode.read(in); }
@Override public String toString() { return this.rootNode.toString(); }
@Override public void write(final DataOutput out) throws IOException { this.rootNode.write(out); }