// Search finds all matching keys according to stype (SearchType).
Search finds all matching keys according to stype (SearchType).
// Search finds all matching keys according to stype ( SearchType ) .
func (t *Trie) Search(key string, stype SearchType) []string {
	switch stype {
	case SearchExactly:
		if _, ok := t.Find(key); ok {
			return []string{key}
		}
	case SearchByPrefix:
		return t.FindByPrefix(key)
	case SearchLongestMatchingPrefix:
		if k, _, ok := t.FindLongestMatchingPrefix(key); ok {
			return []string{k}
		}
	case SearchMatcingPrefix:
		if keys, ok := t.FindMatchingPrefix(key); ok {
			return keys
		}
	case SearchApproximate:
		return t.FindByFuzzy(key)
	case SearchAllRelativeKey:
		return t.FindRelative(key)
	}
	return nil
}
func ( t * Trie ) Search ( key string , stype SearchType ) [ ] string { switch stype { case SearchExactly : if _ , ok := t . Find ( key ) ; ok { return [ ] string { key } } case SearchByPrefix : return t . FindByPrefix ( key ) case SearchLongestMatchingPrefix : if k , _ , ok := t . FindLongestMatchingPrefix ( key ) ; ok { return [ ] string { k } } case SearchMatcingPrefix : if keys , ok := t . FindMatchingPrefix ( key ) ; ok { return keys } case SearchApproximate : return t . FindByFuzzy ( key ) case SearchAllRelativeKey : return t . FindRelative ( key ) } return nil }
Search finds all matching keys according to stype (SearchType).
Search finds all matching keys according to stype ( SearchType ) .