/** * delete child from this node * @param childName the string name of the child to * be deleted */ void deleteChild(String childName) { synchronized(children) { if (!children.containsKey(childName)) { return; } TrieNode childNode = children.get(childName); // this is the only child node. if (childNode.getChildren().length == 1) { childNode.setParent(null); children.remove(childName); } else { // their are more child nodes // so just reset property. childNode.setProperty(false); } } }
/** * delete child from this node * @param childName the string name of the child to * be deleted */ void deleteChild(String childName) { synchronized(children) { if (!children.containsKey(childName)) { return; } TrieNode childNode = children.get(childName); // this is the only child node. if (childNode.getChildren().length == 1) { childNode.setParent(null); children.remove(childName); } else { // their are more child nodes // so just reset property. childNode.setProperty(false); } } }
/** * add a path to the path trie * @param path */ public void addPath(String path) { if (path == null) { return; } String[] pathComponents = path.split("/"); TrieNode parent = rootNode; String part = null; if (pathComponents.length <= 1) { throw new IllegalArgumentException("Invalid path " + path); } for (int i=1; i<pathComponents.length; i++) { part = pathComponents[i]; if (parent.getChild(part) == null) { parent.addChild(part, new TrieNode(parent)); } parent = parent.getChild(part); } parent.setProperty(true); }
/** * delete child from this node * @param childName the string name of the child to * be deleted */ void deleteChild(String childName) { synchronized(children) { if (!children.containsKey(childName)) { return; } TrieNode childNode = children.get(childName); // this is the only child node. if (childNode.getChildren().length == 1) { childNode.setParent(null); children.remove(childName); } else { // their are more child nodes // so just reset property. childNode.setProperty(false); } } }
/** * add a path to the path trie * @param path */ public void addPath(String path) { if (path == null) { return; } String[] pathComponents = path.split("/"); TrieNode parent = rootNode; String part = null; if (pathComponents.length <= 1) { throw new IllegalArgumentException("Invalid path " + path); } for (int i=1; i<pathComponents.length; i++) { part = pathComponents[i]; if (parent.getChild(part) == null) { parent.addChild(part, new TrieNode(parent)); } parent = parent.getChild(part); } parent.setProperty(true); }
/** * add a path to the path trie * @param path */ public void addPath(String path) { if (path == null) { return; } String[] pathComponents = path.split("/"); TrieNode parent = rootNode; String part = null; if (pathComponents.length <= 1) { throw new IllegalArgumentException("Invalid path " + path); } for (int i=1; i<pathComponents.length; i++) { part = pathComponents[i]; if (parent.getChild(part) == null) { parent.addChild(part, new TrieNode(parent)); } parent = parent.getChild(part); } parent.setProperty(true); }