How to implement a simple autocomplete function?

I would like to implement a simple class (in Java) that will allow me to register and unregister strings, and based on the current set of strings, will automatically fill in the given string. Thus, the interface will be:

  • void add (String)
  • void remove (String)
  • String complete (String)

What is the best way to do this in terms of algorithms and data structures?

+3
source share
6 answers

You should consider using PATRICIA trie for a data structure. Search for "patricia trie" on Google and you will find a lot of information ...

+4
source

The sequence of data that you use is called a triple search tree.

JavaWorld www.javaworld.com/javaworld/jw-02-2001/jw-0216-ternary.html

+3

- , . , , . , , .

TreeList . , , . , , .

0

, ...

Google Code. java, HTTP AJAX.

, . !

0

Regular expressions.

-2
source

Source: https://habr.com/ru/post/1696964/


All Articles