/*
 * Copyright 2012 Takao Nakaguchi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.trie4j;

public interface Trie {
	/**
	 * returns inserted word count(equals to terminal node count)
	 * @return inserted word count
	 */
	int size();

	/**
	 * retuns root node.
	 * @return root node.
	 */
	Node getRoot();

	/**
	 * returns true if trie contains word.
	 * @param word word to check it contained.
	 * @return true if trie contains word.
	 */
	boolean contains(String word);

	int findWord(CharSequence chars, int start, int end, StringBuilder word);
	
	Iterable<String> commonPrefixSearch(String query);
	
	Iterable<String> predictiveSearch(String prefix);

	/**
	 * insert word.
	 * @param word word to insert.
	 */
	void insert(String word);

	void dump();

	/**
	 * shrink buffer size to fit actual node count.
	 */
	void trimToSize();
}

@@ -997,137 +997,993 @@
 ;%0A%0A%09
-int findWord(CharSequence chars, int start, int end, StringBuilder word);%0A%09%0A%09Iterable%3CString%3E commonPrefixSearch(String query);%0A%09
+/**%0A%09 * search trie for word contained in chars. If the word is found, this method%0A%09 * returns the position in chars and add found word to word parameter.%0A%09 * @param chars chars%0A%09 * @param start start position%0A%09 * @param end end position%0A%09 * @param word buffer to append found word. this can be null%0A%09 * @return found position. -1 if no word found.%0A%09 */%0A%09int findWord(CharSequence chars, int start, int end, StringBuilder word);%0A%09%0A%09/**%0A%09 * search trie for words contained in query.%0A%09 * If query is %22helloworld%22 and trie contains %22he%22, %22hello%22 and %22world%22,%0A%09 * the words %22he%22 and %22hello%22 will be found.%0A%09 * @param query query%0A%09 * @return Iterable object which iterates found words.%0A%09 */%0A%09Iterable%3CString%3E commonPrefixSearch(String query);%0A%0A%09/**%0A%09 * search trie for words starting prefix.%0A%09 * If prefix is %22he%22 and trie contains %22he%22, %22hello%22 and %22world%22,%0A%09 * the words %22he%22 and %22hello%22 will be found.%0A%09 * @param prefix prefix%0A%09 * @return Iterable object which iterates found words.%0A%09 */
 %0A%09It

add comments