keysByPrefix method
Iterates through TTMultiMap keys such
that only keys prefixed by keyMapping(
prefix
)
are included.
- If keyMapping
(
prefix
)
is empty then returns empty Iterable. - If
maxPrefixEditDistance
> 0 then search will expand to all keys whose prefix is within a Hamming edit distance ofmaxPrefixEditDistance
or less. For example searching for prefix 'cow' withmaxPrefixEditDistance
= 2 may give: cow,cowboy, chicken, crocodile, canary, cat, dog, donkey, goat, hawk, horse, zonkey
Results are ordered by key as:
- Results where key is prefixed by
prefix
(i.e. prefixEditDistance == 0) ordered lexicographically. - Results of increasing edit distance ordered lexographically.
Throws ArgumentError if prefix
is empty or null.
Implementation
@override
TTIterable<String> keysByPrefix(String prefix,
{int maxPrefixEditDistance = 0}) {
final key = _mapKey(prefix);
final root = _root;
return (identical(root, null) || key.isEmpty)
? TTIterable<String>.empty()
: InOrderKeyIterable<V>(root, _version,
prefixSearchResult:
root.getClosestPrefixDescendant(key.runes.toList()),
maxPrefixEditDistance: maxPrefixEditDistance);
}