Package autocomplete
Class BinarySearchAutocomplete
- java.lang.Object
-
- autocomplete.BinarySearchAutocomplete
-
- All Implemented Interfaces:
Autocomplete
public class BinarySearchAutocomplete extends Object implements Autocomplete
Binary search implementation of theAutocomplete
interface.- See Also:
Autocomplete
-
-
Field Summary
Fields Modifier and Type Field Description private List<CharSequence>
terms
List
of added autocompletion terms.
-
Constructor Summary
Constructors Constructor Description BinarySearchAutocomplete()
Constructs an empty instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(Collection<? extends CharSequence> terms)
Adds the given collection of autocompletion terms.List<CharSequence>
allMatches(CharSequence prefix)
Returns all autocompletion terms that match the given prefix.private static boolean
isPrefixOf(CharSequence prefix, CharSequence term)
Returns true if and only if the given term matches the given prefix.
-
-
-
Field Detail
-
terms
private final List<CharSequence> terms
List
of added autocompletion terms.
-
-
Method Detail
-
addAll
public void addAll(Collection<? extends CharSequence> terms)
Description copied from interface:Autocomplete
Adds the given collection of autocompletion terms.- Specified by:
addAll
in interfaceAutocomplete
- Parameters:
terms
- collection containing elements to be added.
-
allMatches
public List<CharSequence> allMatches(CharSequence prefix)
Description copied from interface:Autocomplete
Returns all autocompletion terms that match the given prefix.- Specified by:
allMatches
in interfaceAutocomplete
- Parameters:
prefix
- search query.
-
isPrefixOf
private static boolean isPrefixOf(CharSequence prefix, CharSequence term)
Description copied from interface:Autocomplete
Returns true if and only if the given term matches the given prefix.- Parameters:
prefix
- prefix template.term
- term to check against the prefix.- Returns:
- true if and only if the given term matches the given prefix.
-
-