trie4j/src/kitchensink/java/org/trie4j/patricia/multilayer/MultilayerPatriciaTrie.java
private static void enumLetters(org.trie4j.Node node, String prefix, List<String> letters){
		org.trie4j.Node[] children = node.getChildren();
		if(children == null) return;
		for(org.trie4j.Node child : children){
			String text = prefix + new String(child.getLetters());
			if(child.isTerminate()) letters.add(text);
			enumLetters(child, text, letters);
		}
	}
private static void enumLetters(org.trie4j.Node node, String prefix, List<String> letters){
		org.trie4j.Node[] children = node.getChildren();
		if(children == null) return;
		for(org.trie4j.Node child : children){
			String text = prefix + new String(child.getLetters());
			if(child.isTerminate()) letters.add(text);
			enumLetters(child, text, letters);
		}
	}
private static void enumLetters ( org . trie4j . Node node , String prefix , List < String > letters ) { org . trie4j . Node [ ] children = node . getChildren ( ) ; if ( children == null ) return ; for ( org . trie4j . Node child : children ) { String text = prefix + new String ( child . getLetters ( ) ) ; if ( child . isTerminate ( ) ) letters . add ( text ) ; enumLetters ( child , text , letters ) ; } }
/
@Override
public Iterable<String> commonPrefixSearch(String query) {
List<String> ret = new ArrayList<String>();
char[] queryChars = query.toCharArray();
int cur = 0;
Node node = root;
while(node != null){
char[] letters = node.getLetters();
if(letters.length > (queryChars.length - cur)) return ret;
for(int i = 0; i < letters.length; i++){
if(letters[i] != queryChars[cur + i]) return ret;
}
if(node.isTerminate()){
ret.add(new String(queryChars, 0 , cur + letters.length));
}
cur += letters.length;
if(queryChars.length == cur) return ret;
node = node.getChild(queryChars[cur]);
}
return ret;
}
/